From: | Allen Landsidel <alandsidel(at)gmail(dot)com> |
---|---|
To: | Postgresql Performance <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: Strange (?) Index behavior? |
Date: | 2004-11-05 16:54:02 |
Message-ID: | 88f1825a0411050854417e1198@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On Fri, 5 Nov 2004 10:32:43 -0500, Allen Landsidel <alandsidel(at)gmail(dot)com> wrote:
> On Fri, 05 Nov 2004 10:07:38 -0500, Rod Taylor <pg(at)rbt(dot)ca> wrote:
>
>
> > > It seems to me that a query saying "SELECT column FROM table WHERE
> > > column LIKE 'AA%';" should be just as fast or very close to the first
> > > case up above. However, explain tells me that this query is not using
> > > the index above, which is what's not making sense to me.
> >
> > It looks for an exact expression match, and doesn't know about values
> > which are equal.
> >
> > You can provide both clauses.
> >
> > WHERE column LIKE 'A%' and column LIKE 'AA%';
>
> I see. That's not really optimal either however as you can probably
> see already.. adding AB, AC, AD...AZ is likely to be pretty bogus and
> at the least is time consuming.
I see now that you mean to add that to the SELECT clause and not the
index, my mistake.
> Perhaps.. SELECT column FROM (SELECT column FROM table WHERE column
> LIKE 'A%') AS sq WHERE column LIKE 'AA%';
>
> The query planner thinks this will be pretty fast indeed, and does use
> the index I am after.
This was indeed pretty fast. About 7 seconds, as was modifying the
WHERE as suggested above.
-Allen
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Fuhr | 2004-11-05 17:45:34 | Re: Checking = with timestamp field is slow |
Previous Message | Merlin Moncure | 2004-11-05 15:33:38 | postgresql amd-64 |