Skip to content

Instantly share code, notes, and snippets.

@jrun
Created September 18, 2012 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrun/3744021 to your computer and use it in GitHub Desktop.
Save jrun/3744021 to your computer and use it in GitHub Desktop.
Time postgres queries using dtrace - WIP
#!/usr/bin/env dtrace -s
#pragma D option quiet
#pragma D option switchrate=10hz
/*
docs:
http://www.postgresql.org/docs/9.2/interactive/dynamic-trace.html
*/
postgres*::query-start
{
start = timestamp;
}
postgres*::query-done
{
end = timestamp;
elapsed = end - start;
/* microseconds */
printf("%d - %s\n\n", (elapsed / 1000), copyinstr(arg0));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment