From: | "Alexander Staubo" <alex(at)purefiction(dot)net> |
---|---|
To: | "Guillaume Smet" <guillaume(dot)smet(at)gmail(dot)com> |
Cc: | pgsql-performance <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: Estimation problem with a LIKE clause containing a / |
Date: | 2007-11-07 13:25:40 |
Message-ID: | 88daf38c0711070525r1e7d6daft56970045de0ec8f4@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-performance |
On 11/7/07, Guillaume Smet <guillaume(dot)smet(at)gmail(dot)com> wrote:
> While studying a query taking forever after an ANALYZE on a never
> analyzed database (a bad estimate causes a nested loop on a lot of
> tuples), I found the following problem:
[snip]
> Total runtime: 31.097 ms
[snip]
> Total runtime: 31.341 ms
[snip]
> Total runtime: 34.778 ms
>
> Which is a really good estimate.
That's a difference of less than *three milliseconds* -- a difference
probably way within the expected overhead of running "explain
analyze". Furthermore, all three queries use the same basic plan: a
sequential scan with a filter. At any rate you're microbenchmarking in
a way that is not useful to real-world queries. In what way are these
timings a problem?
Have you tried using an index which supports prefix searches? The
text_pattern_ops operator class lets yo do this with a plain B-tree
index:
create index cms_items_ancestors_index on cms_items (ancestors
text_pattern_ops);
analyze cms_items;
Now all "like 'prefix%'" queries should use the index.
Alexander.
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2007-11-07 13:35:31 | Re: A small rant about coding style for backend functions |
Previous Message | Peter Eisentraut | 2007-11-07 13:24:14 | Re: pg_resetxlog output clarification |
From | Date | Subject | |
---|---|---|---|
Next Message | Guillaume Smet | 2007-11-07 13:38:04 | Re: Estimation problem with a LIKE clause containing a / |
Previous Message | Guillaume Smet | 2007-11-07 12:53:16 | Estimation problem with a LIKE clause containing a / |