If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > PostgreSQL > # of queries executed vs execution time?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-28-11, 12:57
ss1289 ss1289 is offline
Registered User
 
Join Date: Jan 2009
Posts: 12
# of queries executed vs execution time?

Say I have 2 applications that do that exact same thing on the front end, except for the queries that they run on the backend.
The 1st one runs just 1 big query to gather all the info and it takes 5 seconds.
The 2nd runs 30 smaller queries to gather the same info but it takes less time, say 3 seconds.

Is there an issue with running way more queries if it has a faster execution time compared to 1 or 2 larger queries?
I usually go the route of trying to execute fewer queries, but I'm starting to question myself.

Thanks
Reply With Quote
  #2 (permalink)  
Old 12-31-11, 11:12
arvindps arvindps is offline
Registered User
 
Join Date: Aug 2011
Posts: 27
Mutiple queryies will eventually loose out to Single query because of default resource allocation , connectionsset , concurrent network traffic

As data grows, even smaller queries will show signs of aging.

The best method is to use indexes and set query definition to take optimum use of those indexes.

anyway pls. post example query for more infor

(use Logs to check for better results)

>> Pg_log


Logs are stored in Installationfolder/data/pg_log folder. While log settings are placed in postgresql.conf file.

Log format is usually set as stderr. But CSV log format is recommended. In order to enable CSV format change in

- log_destination = 'stderr,csvlog'
- logging_collector = on

In order to log all queries, very usefull for new installations, set min. execution time of a query that will be logged

- log_min_duration_statement = 0

In order to view active Queries on your database, use

- SELECT * FROM pg_stat_activity

To log specific queries set query type

- log_statement = 'all' # none, ddl, mod, all
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On