Re: select count(*) and limit

From: Verena Ruff <lists(at)triosolutions(dot)at>
To: Oscar Rodriguez Fonseca <info(at)vraniscci(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: select count(*) and limit
Date: 2006-05-18 15:45:34
Message-ID: 446C969E.60109@triosolutions.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Oscar Rodriguez Fonseca schrieb:
> TABLE IN DB:
>
>
> number_times | user_name | last_login
> ----------------------------------------
> 1 | Paul | 11-12-2005
> 4 | Mary | 08-11-2005
> 5 | Charles | 01-02-2005
>
> [...]
>
> SELECT count(*) AS number_times,NULL AS user_name,NULL as last_login \
> FROM table UNION ALL SELECT * FROM table LIMIT 2;
>
> This has the practical drawback that you need an integer column in your
> table to get the query working as expected and the design drawback that
> it is a little bit weird and somewhat non-standard way of querying.
>
I think this is a little bit to weired. It should be possible for
another person what I am doing without explaing such a lot.

> BTW, I had a similar problem and solved it storing the full result list
> in a temporal variable on the server but "session-wise" (when the user
> opens another unrelated page, the application frees the variable). This
> is possible in my case because my app won't have more than 10 clients
> at once and therefore it don't represent much memory overhead
This is possible if there are only little users and only a few hundred
records. I have only few users, too, but some tenthousonds records and I
don't think it would be a good idea storing them completly in the
servers memory.

Regards,
Verena

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Verena Ruff 2006-05-18 16:28:31 Re: select count(*) and limit
Previous Message Oscar Rodriguez Fonseca 2006-05-18 15:33:19 Re: select count(*) and limit