0

I am using PostgreSQL with c++ and I am trying to analyse the performance of different queries. I tried using EXPLAIN ANALYZE but I can't figure out how to print the result on screen. How can I do so?

4
  • What exactly do you mean with "print the result on screen". When running EXPLAIN ANALYZE, the result returned from the server will be the execution plan. So you'd print it as any other result you obtain through your SQL client. How exactly are you running the EXPLAIN? Which tool are you using? Commented May 2, 2011 at 9:14
  • I tried to print it with: res1 = PQexec(conn, explainQuery.c_str()); for (int i= 0; i < PQntuples(res1); i++) { for (int j = 0; j < nFields; j++) { temp_value = PQgetvalue(res1, i, j); cout << temp_value; } } Commented May 2, 2011 at 9:53
  • Should work as it is "just a result" But I don't do C++, so I cannot tell for sure. Did you try it with psql? Commented May 2, 2011 at 9:59
  • It's weird but the same syntax seems to work now. I guess I messed up while declaring variables or something. Thanks though. :) Commented May 2, 2011 at 10:13

1 Answer 1

1

The psql command-line tool will run queries and display the results.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.