Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
970 views
in Q2A Core by
ex:

 

when my table qa_posts is 687806,it is too slow,i found is sql

SELECT COUNT(DISTINCT (userid) ) FROM qa_posts;

1 Answer

+2 votes
by

That query is executed within the 'Stats' panel of the 'Admin' section, so it's not something which is part of the normal flow of the site.

But in any event, it's also not all that slow because there's an index on userid in qa_posts, and it can be executed without reading the table rows at all. You can see this for yourself by running this in MySQL:

EXPLAIN SELECT COUNT(DISTINCT (userid) ) FROM qa_posts;

The Using index in the Extra column means that the rows weren't accessed.

Anyway if you find any other slow queries I'd appreciate you letting me know, since as far as I'm aware there aren't any apart from ones like this example which are for the site admin only.

FYI you can switch on QA_DEBUG_PERFORMANCE in qa-config.php to see a list of queries at the bottom of each page view, including their running time.

...