Running queries to fetch a count of hits in DB on several things

Поиск
Список
Период
Сортировка
От Mohamed
Тема Running queries to fetch a count of hits in DB on several things
Дата
Msg-id 861fed220901160941v478bec2eq724a249f114416d2@mail.gmail.com
обсуждение исходный текст
Ответы Running queries to fetch a count of hits in DB on several things
Список pgsql-general
Hi, this is basically what I would like to improve : 

1) A user searches for a product on category and location. 

a) The query is run and the result (limit 30) are returned and shown.
b) The same query is ran again but now I return the count on how many matches there was totally. (This has to be possible to include somehow in the above, without the limit it would return all rows and therefor the number of matches as well)
c) The same query is ran again but now I return the count on how many matches there was in each location
c)  --- " " --- count on category.
d) --- " " ---  count on how many that was used or new. 
etc...


How can I improve this? Seems so unnecessary to have to run the query on every count I want to do when its the same query hitting the same relation with a slight modification in each? Is there a way or should I just forget about it and run them over and over again? I am guessing using functions could be possible but now so little about them and how to run them from Java. There might be 1000 or more users on the website simultaneously and I am guessing this could be a real downside...

Thanks / Moe





























В списке pgsql-general по дате отправления:

Предыдущее
От: David Fetter
Дата:
Сообщение: Re: [HACKERS] Question regarding new windowing functions in 8.4devel
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [HACKERS] Question regarding new windowing functions in 8.4devel