Results 1 to 9 of 9
  1. #1
    Join Date
    Jul 2001
    Location
    Bangalore, India
    Posts
    28

    Unanswered: Timestamp of a SQL select statement

    Hi,
    Does DB2 store any where the timestamp of SELECT statement?
    Basically I want to know when a particular SELECT statement was run last..
    Thanks in advance..
    Ravi

  2. #2
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    DB2 does not log select statements.

  3. #3
    Join Date
    Jul 2001
    Location
    Bangalore, India
    Posts
    28
    I found out that we can use Statement event monitor to log SQLs..
    it records start time and end time of the executed query alongwith some other info..
    thanks..
    Ravi

  4. #4
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    If you are talking about the future and not the past, it might be easier to log it yourself into a seperate table you create. This extra insert would be more than offsett by the overhead caused by the event monitor.

  5. #5
    Join Date
    Jul 2001
    Location
    Bangalore, India
    Posts
    28
    Hi Marcus,
    could you tell me how do we log it in a seperate table? I want to log the execution time also along with the SQL query.
    Thanks in advance
    Ravi

  6. #6
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    I don't know what query mechanism you are using (such as a third party tool) but if you can run a script or procedure then it can contain the regular query and also SQL insert statements to log the information you want.

    Have the script or procedure contain 3 SQL statements. The first is an insert (into a table you create) to log the start of the query. The next query is the regular query that is always run. The last insert would be to log the end of query execution.

    There is also a program called db2batch that is supplied with DB2 to provides information in the output about how long it took to execute the SQL statement. This program was specifically designed for use in benchmarking.
    Last edited by Marcus_A; 09-08-03 at 23:34.

  7. #7
    Join Date
    Jul 2001
    Location
    Bangalore, India
    Posts
    28
    Hi Marcus,
    thanks a lot for the reply, it was really helpful
    Ravi

  8. #8
    Join Date
    Dec 2002
    Posts
    10
    in V8, snapshots can write into table and you can use this feature to log the time when the SQLs ran

  9. #9
    Join Date
    Jul 2001
    Location
    Bangalore, India
    Posts
    28
    Hi Swaminaathan,
    thanks for the info.. It would be great if you could tell me me how to put the snapshot results in a table.
    Thanks
    Ravi

Posting Permissions

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