I dk.edb.database, skrev Jesper Krogh:
> sd=> explain analyse select count(*) from tabwithoutblob where data like '%test%';
> QUERY PLAN
> ----------------------------------------------------------------------------------------------------------
> Aggregate (cost=22.52..22.52 rows=1 width=0) (actual time=77.83..77.83 rows=1 loops=1)
> -> Seq Scan on tabwithoutblob (cost=0.00..22.50 rows=8 width=0) (actual time=0.78..76.64 rows=1560 loops=1)
> Filter: (data ~~ '%test%'::text)
> Total runtime: 77.90 msec
> (4 rows)
>
> sd=>
> sd=> explain analyse select count(*) from tabwithblob where data like '%test%';
> QUERY PLAN
> ---------------------------------------------------------------------------------------------------------------------
> Aggregate (cost=29831.05..29831.05 rows=1 width=0) (actual time=20883.02..20883.03 rows=1 loops=1)
> -> Seq Scan on tabwithblob (cost=0.00..29829.06 rows=796 width=0) (actual time=19230.43..20881.65 rows=1560 loops=1)
> Filter: (data ~~ '%test%'::text)
> Total runtime: 20883.12 msec
> (4 rows)
> sd=>
Ved at clustre tabellen efter "data" gave det et speedup til 317 msec..
så der var klart noget at hente
sd=> explain analyse select count(*) from traces where tracefilename like '%test%';
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------
Aggregate (cost=12784.11..12784.11 rows=1 width=0) (actual time=317.35..317.35 rows=1 loops=1)
-> Seq Scan on tabwithblob (cost=0.00..12781.96 rows=858 width=0) (actual time=242.13..316.18 rows=1560 loops=1)
Filter: (data ~~ '%test%'::text)
Total runtime: 317.42 msec
(4 rows)
sd=>
--
../Jesper Krogh, jesper@krogh.cc, Jabber ID: jesper@jabbernet.dk
Jabber - Det eneste instant messaging system der sikrer DIT privatliv.