Sign up ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I am using Postgres as my Database. I need to know whether I can extract all the queries that got executed with out logging them as logging all the queries will degrade the performance of database. So, provide a way I can get all the queries that got executed with out logging the queries.

share|improve this question
2  
So, you're looking for magic? If you don't log what is ran, how can you know what has been ran? – Max Vernon Jan 6 at 6:45
    
Ok then How a tool that monitors the database(profiler) like SQLProfiler in case of postgres gets all the queries with out using log files...please let me know.. – Manoj Sreerama Jan 6 at 10:33
    
Point is something must be running to gather those statistics or you won't see them. – Max Vernon Jan 6 at 14:00

2 Answers 2

up vote 0 down vote accepted

If not logging the queries, there is no chance. However, if you are looking for some statistics to find e.g. queries which are executed very often and therefore an optimization could make sense: Checkout pg_stat_statment-extension

share|improve this answer
    
pg_stat_statements works fine..But, it will not give the details like processid(pid) of process which executed the query...(or) client_address etc..Help me on finding them.. – Manoj Sreerama Jan 29 at 12:10
    
Yes. The only way doing this I know of is logging the queries or maybe the wireshark approach is working. Didn't know it before. – frlan Jan 29 at 12:21

You can try by capturing the traffic with tshark and some filters : https://www.wireshark.org/docs/dfref/p/pgsql.html

It will not be very proper but should work.

share|improve this answer
    
This will only work if not using SSL encrypted connection, right? – frlan Jan 8 at 9:18
    
yes, only without ssl. – anayrat Jan 8 at 10:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.