Re: What's faster?

From: Alban Hertroys <alban(at)magproductions(dot)nl>
To: Silas Justiniano <silasju(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: What's faster?
Date: 2006-02-09 15:50:28
Message-ID: 43EB64C4.2090003@magproductions.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)magproductions(dot)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//

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jennifer Drake 2006-02-09 15:50:38 PQputline error with pg_restore
Previous Message Dan Armbrust 2006-02-09 15:27:29 Re: Create a new database from JDBC?