From aa@devshock.com Thu Dec 16 19:18:57 2010 Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 13530133655C for ; Thu, 16 Dec 2010 15:18:57 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 78628-06-4 for ; Thu, 16 Dec 2010 19:18:50 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-yx0-f174.google.com (mail-yx0-f174.google.com [209.85.213.174]) by mail.postgresql.org (Postfix) with ESMTP id C0F121337BC3 for ; Thu, 16 Dec 2010 15:18:49 -0400 (AST) Received: by yxt3 with SMTP id 3so1849978yxt.19 for ; Thu, 16 Dec 2010 11:18:49 -0800 (PST) Received: by 10.236.109.11 with SMTP id r11mr2245231yhg.95.1292527129138; Thu, 16 Dec 2010 11:18:49 -0800 (PST) Received: from ANIBALVAIO ([190.128.222.90]) by mx.google.com with ESMTPS id j64sm238193yha.35.2010.12.16.11.18.46 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 16 Dec 2010 11:18:48 -0800 (PST) From: "Anibal David Acosta" To: Subject: using limit Date: Thu, 16 Dec 2010 16:18:50 -0300 Message-ID: <001f01cb9d56$13d69790$3b83c6b0$@devshock.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0020_01CB9D3C.EE8BD090" X-Mailer: Microsoft Outlook 14.0 Content-Language: es-py Thread-Index: AcudVWq9DKLKRaRwRb+9F4g65/D4MQ== X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-1.9, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7 X-Spam-Level: X-Archive-Number: 201012/110 X-Sequence-Number: 36339 This is a multipart message in MIME format. ------=_NextPart_000_0020_01CB9D3C.EE8BD090 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 ------=_NextPart_000_0020_01CB9D3C.EE8BD090 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

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

------=_NextPart_000_0020_01CB9D3C.EE8BD090-- From michael@aers.ca Thu Dec 16 20:30:34 2010 Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 55DC61337B68 for ; Thu, 16 Dec 2010 16:30:34 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 44509-03 for ; Thu, 16 Dec 2010 20:30:27 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from na3sys009aog113.obsmtp.com (na3sys009aog113.obsmtp.com [74.125.149.209]) by mail.postgresql.org (Postfix) with SMTP id 3B196133655C for ; Thu, 16 Dec 2010 16:30:25 -0400 (AST) Received: from source ([209.85.210.177]) by na3sys009aob113.postini.com ([74.125.148.12]) with SMTP ID DSNKTQp24Qw7mufAGJzPZWNucVlQJ2jeebj0@postini.com; Thu, 16 Dec 2010 12:30:26 PST Received: by mail-iy0-f177.google.com with SMTP id 21so2063048iyj.22 for ; Thu, 16 Dec 2010 12:30:25 -0800 (PST) Received: by 10.231.33.198 with SMTP id i6mr6744991ibd.10.1292527406290; Thu, 16 Dec 2010 11:23:26 -0800 (PST) From: Michael Holt References: <001f01cb9d56$13d69790$3b83c6b0$@devshock.com> In-Reply-To: <001f01cb9d56$13d69790$3b83c6b0$@devshock.com> MIME-Version: 1.0 X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AcudVWq9DKLKRaRwRb+9F4g65/D4MQAANVEw Date: Thu, 16 Dec 2010 11:23:25 -0800 Message-ID: Subject: Re: using limit To: Anibal David Acosta , pgsql-admin@postgresql.org Content-Type: multipart/alternative; boundary=0022152d84a1ea192904978bfc03 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-4.199 tagged_above=-10 required=5 tests=BAYES_00=-1.9, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_MED=-2.3 X-Spam-Level: X-Archive-Number: 201012/114 X-Sequence-Number: 36343 --0022152d84a1ea192904978bfc03 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable This really depends on the type of query you=92re talking about. If there= =92s only one row in the table you=92re querying then no, I don=92t think it=92l= l change anything. If you=92re querying a single row using a primary key it shouldn=92t change anything. If you=92re doing an aggregate query, say a su= m of a bunch of rows, it also won=92t improve performance. If you=92re doing a query on a table with multiple rows and not filtering b= y a primary key or other unique index then yes, it will improve the query. *From:* pgsql-admin-owner@postgresql.org [mailto: pgsql-admin-owner@postgresql.org] *On Behalf Of *Anibal David Acosta *Sent:* Thursday, December 16, 2010 11:19 AM *To:* pgsql-admin@postgresql.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 --0022152d84a1ea192904978bfc03 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: quoted-printable

This really depends on the type of query you=92re talking about. If there= =92s only one row in the table you=92re querying then no, I don=92t think i= t=92ll change anything. If you=92re querying a single row using a primary k= ey it shouldn=92t change anything. If you=92re doing an aggregate query, sa= y a sum of a bunch of rows, it also won=92t improve performance.

=A0

If you=92re doing a query on a= table with multiple rows and not filtering by a primary key or other uniqu= e index then yes, it will improve the query.

=A0

From: pgsql-admin-owner@postgre= sql.org [mailto:pgs= ql-admin-owner@postgresql.org] On Behalf Of Anibal David Acosta<= br> Sent: Thursday, December 16, 2010 11:19 AM
To: pgsql-admin@postgresql.org
Sub= ject: [ADMIN] using limit

=A0

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=A0 the LIMIT 1 could improve the performance?=

=A0

If I use my logic, the= LIMIT 1 instruction tell to postgres that stop searching when found 1 reco= rd, but maybe it is unnecessary

=A0

=A0

Thanks

=A0

Anibal

--0022152d84a1ea192904978bfc03-- From aa@devshock.com Thu Dec 16 19:41:06 2010 Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 8AC431336971 for ; Thu, 16 Dec 2010 15:41:06 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 28937-04 for ; Thu, 16 Dec 2010 19:40:58 +0000 (UTC) X-Greylist: delayed 00:07:15.120336 by SQLgrey-1.7.6 Received: from mail-gw0-f49.google.com (mail-gw0-f49.google.com [74.125.83.49]) by mail.postgresql.org (Postfix) with ESMTP id 8D5C5133655C for ; Thu, 16 Dec 2010 15:40:57 -0400 (AST) Received: by gwj20 with SMTP id 20so2359764gwj.22 for ; Thu, 16 Dec 2010 11:40:57 -0800 (PST) Received: by 10.147.125.7 with SMTP id c7mr257552yan.30.1292528022166; Thu, 16 Dec 2010 11:33:42 -0800 (PST) Received: from ANIBALVAIO ([190.128.222.90]) by mx.google.com with ESMTPS id g78sm185996yhd.22.2010.12.16.11.33.39 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 16 Dec 2010 11:33:41 -0800 (PST) From: "Anibal David Acosta" To: "'Michael Holt'" , References: <001f01cb9d56$13d69790$3b83c6b0$@devshock.com> In-Reply-To: Subject: Re: using limit Date: Thu, 16 Dec 2010 16:33:42 -0300 Message-ID: <002d01cb9d58$27fdabd0$77f90370$@devshock.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_002E_01CB9D3F.02B38110" X-Mailer: Microsoft Outlook 14.0 Content-Language: es-py Thread-Index: AQLyZTQQhLHmIwgi3D6D5gDDSF90zgFAmnnxkUvferA= X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-1.9, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7 X-Spam-Level: X-Archive-Number: 201012/112 X-Sequence-Number: 36341 This is a multipart message in MIME format. ------=_NextPart_000_002E_01CB9D3F.02B38110 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Is a table with 10 million of rows with a primary key but conditions used in select are not part of PK. My table is like this: Column 1 - PK Column 2 - Indexed Column 3 - Indexed Column 2 and Column 3 are Indexed in the same index but they are not mark as unique or PK The Query is like this: Select column1 from myTable where Column2 between X and Y I am expecting just one record De: Michael Holt [mailto:michael@aers.ca] Enviado el: jueves, 16 de diciembre de 2010 04:23 p.m. Para: Anibal David Acosta; pgsql-admin@postgresql.org Asunto: RE: [ADMIN] using limit 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@postgresql.org [mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Anibal David Acosta Sent: Thursday, December 16, 2010 11:19 AM To: pgsql-admin@postgresql.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 ------=_NextPart_000_002E_01CB9D3F.02B38110 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Is a table with 10 million of rows = with a primary key but conditions used in select are not part of = PK.

 

My table is = like this:

Column 1 – PK

Column 2 = – Indexed

Column 3 – = Indexed

 

Column 2 = and Column 3 are Indexed in the same index but they are not mark as = unique or PK

 

The Query = is like this:

Select column1 from myTable where = Column2 between X and Y

 

I am = expecting just one record

 

 

 

De: Michael = Holt [mailto:michael@aers.ca]
Enviado el: jueves, 16 de = diciembre de 2010 04:23 p.m.
Para: Anibal David Acosta; = pgsql-admin@postgresql.org
Asunto: RE: [ADMIN] using = limit

 

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@postgr= esql.org [mailto:pgsql-admin-owner@postgr= esql.org] On Behalf Of Anibal David Acosta
Sent: = Thursday, December 16, 2010 11:19 AM
To: pgsql-admin@postgresql.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

------=_NextPart_000_002E_01CB9D3F.02B38110-- From michael@aers.ca Thu Dec 16 19:46:41 2010 Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id A45D21336B42 for ; Thu, 16 Dec 2010 15:46:41 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 85252-09 for ; Thu, 16 Dec 2010 19:46:34 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from na3sys009aog111.obsmtp.com (na3sys009aog111.obsmtp.com [74.125.149.205]) by mail.postgresql.org (Postfix) with SMTP id 658A5133655C for ; Thu, 16 Dec 2010 15:46:32 -0400 (AST) Received: from source ([209.85.210.179]) by na3sys009aob111.postini.com ([74.125.148.12]) with SMTP ID DSNKTQpskpv2pKh5no0Uf1MrK9u5zh+DLadc@postini.com; Thu, 16 Dec 2010 11:46:33 PST Received: by mail-iy0-f179.google.com with SMTP id 19so1771822iye.10 for ; Thu, 16 Dec 2010 11:46:26 -0800 (PST) Received: by 10.231.35.201 with SMTP id q9mr6632881ibd.185.1292528786133; Thu, 16 Dec 2010 11:46:26 -0800 (PST) From: Michael Holt References: <001f01cb9d56$13d69790$3b83c6b0$@devshock.com> <002d01cb9d58$27fdabd0$77f90370$@devshock.com> In-Reply-To: <002d01cb9d58$27fdabd0$77f90370$@devshock.com> MIME-Version: 1.0 X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AQLyZTQQhLHmIwgi3D6D5gDDSF90zgFAmnnxkUvferCAAAUMUA== Date: Thu, 16 Dec 2010 11:46:25 -0800 Message-ID: <4fb832d4d430b6edb5965e662c75334a@mail.gmail.com> Subject: Re: using limit To: Anibal David Acosta , pgsql-admin@postgresql.org Content-Type: multipart/alternative; boundary=0022152d610928d2be04978c4fd9 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-4.199 tagged_above=-10 required=5 tests=BAYES_00=-1.9, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_MED=-2.3 X-Spam-Level: X-Archive-Number: 201012/113 X-Sequence-Number: 36342 --0022152d610928d2be04978c4fd9 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Yes, a limit should speed up your query from the sounds of things. *From:* Anibal David Acosta [mailto:aa@devshock.com] *Sent:* Thursday, December 16, 2010 11:34 AM *To:* 'Michael Holt'; pgsql-admin@postgresql.org *Subject:* RE: [ADMIN] using limit Is a table with 10 million of rows with a primary key but conditions used i= n select are not part of PK. My table is like this: Column 1 =96 PK Column 2 =96 Indexed Column 3 =96 Indexed Column 2 and Column 3 are Indexed in the same index but they are not mark a= s unique or PK The Query is like this: Select column1 from myTable where Column2 between X and Y I am expecting just one record *De:* Michael Holt [mailto:michael@aers.ca] *Enviado el:* jueves, 16 de diciembre de 2010 04:23 p.m. *Para:* Anibal David Acosta; pgsql-admin@postgresql.org *Asunto:* RE: [ADMIN] using limit This really depends on the type of query you=92re talking about. If there= =92s only one row in the table you=92re querying then no, I don=92t think it=92l= l change anything. If you=92re querying a single row using a primary key it shouldn=92t change anything. If you=92re doing an aggregate query, say a su= m of a bunch of rows, it also won=92t improve performance. If you=92re doing a query on a table with multiple rows and not filtering b= y a primary key or other unique index then yes, it will improve the query. *From:* pgsql-admin-owner@postgresql.org [mailto: pgsql-admin-owner@postgresql.org] *On Behalf Of *Anibal David Acosta *Sent:* Thursday, December 16, 2010 11:19 AM *To:* pgsql-admin@postgresql.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 --0022152d610928d2be04978c4fd9 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: quoted-printable

Yes, a limit should speed up your query from the sounds of things.<= /p>

=A0

From: Anibal David Acosta [mail= to:aa@devshock.com]
Sent: Thursday, December 16, 2010 11:34 AM
To: 'Michae= l Holt'; pgsql-admin@post= gresql.org
Subject: RE: [ADMIN] using limit

=A0

Is a table with 10 million of rows with a primary key but con= ditions used in select are not part of PK.

=A0

My table is like this:=

Column 1 = =96 PK

Colum= n 2 =96 Indexed

Column 3 =96 Indexed

=A0

Column 2 and Column 3= are Indexed in the same index but they are not mark as unique or PK=

=A0

The Query is like this:=

Select column1 fro= m myTable where Column2 between X and Y

=A0

I am expecting just one record=

=A0<= /p>

=A0

=A0

De: Michael Hol= t [mailto:michael@aers.ca]
Enviado el: jueves, 16 de diciembre de 2010 04:23 p.m.
Para: Anibal David Acosta; pgsql= -admin@postgresql.org
Asunto: RE: [ADMIN] using limit
<= /p>

=A0

This really depends on the = type of query you=92re talking about. If there=92s only one row in the tabl= e you=92re querying then no, I don=92t think it=92ll change anything. If yo= u=92re querying a single row using a primary key it shouldn=92t change anyt= hing. If you=92re doing an aggregate query, say a sum of a bunch of rows, i= t also won=92t improve performance.

=A0

If you=92re doing a query on a= table with multiple rows and not filtering by a primary key or other uniqu= e index then yes, it will improve the query.

=A0

From: pgsql-admin-owner@postgre= sql.org [mailto:pgs= ql-admin-owner@postgresql.org] On Behalf Of Anibal David Acosta<= br> Sent: Thursday, December 16, 2010 11:19 AM
To: pgsql-admin@postgresql.org
Sub= ject: [ADMIN] using limit

=A0

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=A0 the LIMIT 1 could improve the performance?=

=A0

If I use my logic, the= LIMIT 1 instruction tell to postgres that stop searching when found 1 reco= rd, but maybe it is unnecessary

=A0

=A0

Thanks

=A0

Anibal

--0022152d610928d2be04978c4fd9--