Обсуждение: SELECT TOP _x_ ??

Поиск
Список
Период
Сортировка

SELECT TOP _x_ ??

От
"Justin Long"
Дата:
In Microsoft SQL Server you could issue a command
SELECT TOP 5 * FROM database...


The top 5 indicator would mean to take the top 5 records that matched the
criteria. I can't seem to find any way to do this in PostgreSQL. I have a
database of 385 records (which will grow rapidly over the next few months)
and it takes better than 5 seconds to SELECT from the 385 and then use a
while loop to display the top 4. I can't imagine what it will be like when
we reach, say, 10,000 records! So any suggestions for selecting just the top
5 and speeding the process up a bit?

Any responses will be greatly appreciated. Respond here or to
JustinLong@strategicnetwork.org ...


Never retreat. Never surrender. Never cut a deal with a dragon.
_______________________________________________________________
Justin Long                   CIO / Site Editor
616 Station Square Ct         Network for Strategic Missions
Chesapeake, VA 23320          977 Centerville Trnpk CSB 317
JustinLong@xc.org             Va Beach, VA 23463
Check out our site at:        http://www.strategicnetwork.org



Re: [SQL] SELECT TOP _x_ ??

От
Chris Bitmead
Дата:
Justin Long wrote:
> 
> In Microsoft SQL Server you could issue a command
> 
>         SELECT TOP 5 * FROM database...

SELECT * FROM TABLE LIMIT 5;

You may have to be running 6.5, not sure.

-- 
Chris Bitmead
http://www.bigfoot.com/~chris.bitmead
mailto:chris.bitmead@bigfoot.com


Re: [SQL] SELECT TOP _x_ ??

От
Chris Bitmead
Дата:
Chairudin Sentosa wrote:
> 
> I tried this, did not work.
> 
> ibs=> select * from ibs_subscriber limit 5;
> ERROR:  parser: syntax error at or near "5"
> 
> Regards,
> Chai
> 
> PS: PostgreSQL 6.5 

Which snapshot?

> 
> Chris Bitmead wrote:
> 
> > Justin Long wrote:
> > >
> > > In Microsoft SQL Server you could issue a command
> > >
> > >         SELECT TOP 5 * FROM database...
> >
> > SELECT * FROM TABLE LIMIT 5;
> >
> > You may have to be running 6.5, not sure.
> >
> > --
> > Chris Bitmead
> > http://www.bigfoot.com/~chris.bitmead
> > mailto:chris.bitmead@bigfoot.com


Re: [SQL] SELECT TOP _x_ ??

От
Chairudin Sentosa
Дата:
I tried this, did not work.

ibs=> select * from ibs_subscriber limit 5;
ERROR:  parser: syntax error at or near "5"

Regards,
Chai

PS: PostgreSQL 6.5 snapshot.

Chris Bitmead wrote:

> Justin Long wrote:
> >
> > In Microsoft SQL Server you could issue a command
> >
> >         SELECT TOP 5 * FROM database...
>
> SELECT * FROM TABLE LIMIT 5;
>
> You may have to be running 6.5, not sure.
>
> --
> Chris Bitmead
> http://www.bigfoot.com/~chris.bitmead
> mailto:chris.bitmead@bigfoot.com