Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2009

    Unanswered: # 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.


  2. #2
    Join Date
    Aug 2011
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts