| From: | Michael Holt <michael(at)aers(dot)ca> |
|---|---|
| To: | Anibal David Acosta <aa(at)devshock(dot)com>, pgsql-admin(at)postgresql(dot)org |
| Subject: | Re: using limit |
| Date: | 2010-12-16 19:23:25 |
| Message-ID: | f3f619af829b15d8b901614cef0074ac@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-admin |
This really depends on the type of query you’re talking about. If there’s
only one row in the table you’re querying then no, I don’t think it’ll
change anything. If you’re querying a single row using a primary key it
shouldn’t change anything. If you’re doing an aggregate query, say a sum of
a bunch of rows, it also won’t improve performance.
If you’re doing a query on a table with multiple rows and not filtering by a
primary key or other unique index then yes, it will improve the query.
*From:* pgsql-admin-owner(at)postgresql(dot)org [mailto:
pgsql-admin-owner(at)postgresql(dot)org] *On Behalf Of *Anibal David Acosta
*Sent:* Thursday, December 16, 2010 11:19 AM
*To:* pgsql-admin(at)postgresql(dot)org
*Subject:* [ADMIN] using limit
Hi
I really like to do efficient SQL queries so, my question is if I am
expecting no more than one row from a select, using the LIMIT 1 could
improve the performance?
If I use my logic, the LIMIT 1 instruction tell to postgres that stop
searching when found 1 record, but maybe it is unnecessary
Thanks
Anibal
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Anibal David Acosta | 2010-12-16 19:33:42 | Re: using limit |
| Previous Message | Anibal David Acosta | 2010-12-16 19:18:50 | using limit |