Help on query plan. (was: select like and indexes)
| От | William N. Zanatta |
|---|---|
| Тема | Help on query plan. (was: select like and indexes) |
| Дата | |
| Msg-id | 3E2C5512.1000601@veritel.com.br обсуждение исходный текст |
| Ответы |
Re: Help on query plan. (was: select like and indexes)
Re: Help on query plan. (was: select like and indexes) |
| Список | pgsql-general |
Well guys,
I made a search on the archives and found a message on my issue.
It's subject is: "Why won't the query planner use my index?".
There was a suggestion of setting 'enable_seqscan' to off to see
whether the query planner was chosing the right way or not.
Here goes my results:
access=# explain analyze select * from tbl_access where ip like '12%157';
QUERY PLAN
-------------------------------------------------------------------
Seq Scan on tbl_access (cost=0.00..42519.84 rows=139 width=134)
(actual time=698.03..20504.07 rows=1391 loops=1)
Filter: (ip ~~ '12%157'::text)
Total runtime: 20507.44 msec
(3 rows)
-------------------------------------------------------------------
access=# SET enable_seqscan = off;
SET
access=# explain analyze select * from tbl_access where ip like '12%157';
QUERY PLAN
-------------------------------------------------------------------
Index Scan using teste1 on tbl_access (cost=0.00..63593.03 rows=139
width=134) (actual time=160.69..1177.26 rows=1391 loops=1)
Index Cond: ((ip >= '12'::character varying) AND (ip <
'13'::character varying))
Filter: (ip ~~ '12%157'::text)
Total runtime: 1181.18 msec
(4 rows)
--------------------------------------------------------------------
Well, although PG is chosing for a Sequential Scan, the Index Scan
showed to be much more faster.
Is that a problem with the planner or a normal behavior?
william
--
Perl combines all of the worst aspects of BASIC, C and line noise.
-- Keith Packard
В списке pgsql-general по дате отправления: