Re: What's faster? - Mailing list pgsql-general

From Alban Hertroys
Subject Re: What's faster?
Date
Msg-id 43EB64C4.2090003@magproductions.nl
Whole thread Raw
In response to What's faster?  ("Silas Justiniano" <silasju@gmail.com>)
List pgsql-general
Silas Justiniano wrote:
> Hello all!
>
> I'm performing a query that returns me hundreds of records... but I
> need cut them in pages that have 15 items! (using PHP)
>
> So, is it faster:
>
>   select blablabal from _complex_query
>   if (count($result) > 15) show_pages;
>   show_only_15_rows($result);
>
> or:
>
>   select count(*) from _complex_query
>   if ($result1 > 15) show_pages;
>   select blablabal from _complex_query LIMIT ... (see the LIMIT!)
>   show $result

If you don't care about how many pages you'll get, try:

    select blablabal from _complex_query LIMIT (15+1);
    if (count($result) > 15) show_pages;
    show_only_15_rows($result);

--
Alban Hertroys
alban@magproductions.nl

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
    7500 AK Enschede

//Showing your Vision to the World//

pgsql-general by date:

Previous
From: Dan Armbrust
Date:
Subject: Re: Create a new database from JDBC?
Next
From: Jennifer Drake
Date:
Subject: PQputline error with pg_restore