| From: | WireSpot <wirespot(at)gmail(dot)com> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | query time |
| Date: | 2005-02-02 10:33:05 |
| Message-ID: | b2d4b03805020202336f0ceccb@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
I have a table with about 200.000 entries. Among other things, it
contains an integer field I use as a timestamp, and a variable
character field I use for user names. Certain queries are taking too
long IMO. I'm trying this on both 7.4 and 8.0.
If I do a direct comparison (using =) on the user name field and I
sort by the numeric field, I get about 5 ms. If I do a LIKE on the
user name and I don't sort at all, I get about 5 ms too. But if I use
both LIKE on the user name and sorting on the timestamp, the time
jumps to 2000 ms.
I have indexes on both fields, but I remember reading only one of them
will be used when doing a query.
Is such a serious jump in query times normal or am I doing something wrong?
I'm attaching the explain output for all 3 cases.
| Attachment | Content-Type | Size |
|---|---|---|
| explain.txt | text/plain | 2.2 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Chris Green | 2005-02-02 11:18:44 | Re: When is a blank not a null or '' |
| Previous Message | Troels Arvin | 2005-02-02 10:31:01 | Re: When is a blank not a null or '' |