Results 1 to 2 of 2

Thread: [postgres] How to see how long a statement took

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517

    [postgres] How to see how long a statement took

    psql dbname
    dbname=# EXPLAIN ANALYZE SELECT image_group,imageid, extention, description, username,TO_CHAR(date,'MM/DD/YYYY') as date FROM images WHERE image_group='3382';

    Seq Scan on images (cost=0.00..2366.78 rows=510 width=108) (actual time=103.25..1041.29 rows=1 loops=1)
    Total runtime: 1041.35 msec

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517
    EXPLAIN
    Name
    EXPLAIN — Shows statement execution details

    EXPLAIN [ VERBOSE ] query

    Inputs

    VERBOSE

    Flag to show detailed query plan.
    query

    Any query.

    Outputs

    NOTICE: QUERY PLAN: plan

    Explicit query plan from the Postgres backend.
    EXPLAIN

    Flag sent after query plan is shown.

    Description

    This command outputs details about the supplied query. The default output is the computed query cost. VERBOSE displays the full query plan and cost to your screen, and pretty-prints the plan to the postmaster log file.
    Notes

    There is only sparse documentation on the optimizer's use of cost information in Postgres. General information on cost estimation for query optimization can be found in database textbooks. Refer to the Programmer's Guide in the chapters on indexes and the genetic query optimizer for more information.
    Usage

    To show a query plan for a simple query:

    postgres=> explain select * from foo;
    NOTICE: QUERY PLAN:

    Seq Scan on foo (cost=0.00 size=0 width=4)

    EXPLAIN

    Compatibility

    SQL92

    There is no EXPLAIN statement defined in SQL92.

Posting Permissions

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



Click Here to Expand Forum to Full Width