Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2014
    Posts
    2

    Unanswered: Discover which command was sent to postgreSQL

    Hi guys!

    I'm new here, so forgive me if I'm asking an old question.
    I'm developing a new app but I need to use the same database that the current app uses. So I need to map the queries the old app do. Like this: if I click on "search products" I need to discover how this query was sent to the database, like "SELECT...". Is there a command i can use in postgresql to do that?

    Thanks in advance.

  2. #2
    Join Date
    Aug 2014
    Posts
    2
    I too am new, and also interested in this same question.
    Is there an easy way to send ALL PostgreSQL queries to logs ?
    Last edited by bluegroper; 08-10-14 at 19:34.

  3. #3
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    If you have access to the database config files, you can configure your server to log many different things, including SQL statements.

    in postgresql.conf, look at the log_statement setting. The possible choices are none (default,) ddl, mod (dml,) and all. You'll have to reload the configuration file after changing it.


    If there are a lot of people 'hitting' the database concurrently though, your log files can get quite large.
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


  4. #4
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    The extension pg_stat_statements is probably helpful as well:

    http://www.postgresql.org/docs/curre...tatements.html
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags: http://www.dbforums.com/misc.php?do=bbcode#code

    Tips for good questions:

    http://tkyte.blogspot.de/2005/06/how...questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

  5. #5
    Join Date
    Aug 2014
    Posts
    2
    Thank you all!

    It worked for me.

Posting Permissions

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