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

From Chris
Subject Re: What's faster?
Date
Msg-id 43EABBE0.7080600@gmail.com
Whole thread Raw
In response to What's faster?  ("Silas Justiniano" <silasju@gmail.com>)
List pgsql-general
Hi,

Second option.

For the first option, if your query returns say 10,000 rows then php has
to actually fetch 10,000 rows from the database before anything else
happens even though you're only displaying 15.

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
>
> On the first, I can use pg_num_rows instead of count(), too.
>
> what do you think?


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Request to have VACUUM ignore cost based limits
Next
From: Bruce Momjian
Date:
Subject: Re: Sequences/defaults and pg_dump