25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-28 16:34:13 +01:00

User count performance improvements

SVN Revision: 1086
This commit is contained in:
Christophe Romain 2007-12-20 17:12:45 +00:00
parent 583f2fd19f
commit 1ba15b207c
2 changed files with 19 additions and 7 deletions

View File

@ -6,6 +6,9 @@
* src/mod_pubsub/mod_pubsub.erl: PEP notification bugfix * src/mod_pubsub/mod_pubsub.erl: PEP notification bugfix
* src/odbc/odbc_queries.erl: User count performance improvements
(EJAB-239)
2007-12-20 Badlop <badlop@process-one.net> 2007-12-20 Badlop <badlop@process-one.net>
* src/msgs/zh.msg: Small update (thanks to Shelley Shyan) * src/msgs/zh.msg: Small update (thanks to Shelley Shyan)

View File

@ -147,13 +147,22 @@ list_users(LServer, [{prefix, Prefix},
"limit ~w offset ~w ", [Prefix, Limit, Offset])). "limit ~w offset ~w ", [Prefix, Limit, Offset])).
users_number(LServer) -> users_number(LServer) ->
case ejabberd_config:get_local_option( case element(1, ejabberd_config:get_local_option({odbc_server, LServer})) of
{pgsql_users_number_estimate, LServer}) of mysql ->
ejabberd_odbc:sql_query(
LServer,
"select table_rows from information_schema.tables where table_name='users'");
pgsql ->
case ejabberd_config:get_local_option({pgsql_users_number_estimate, LServer}) of
true -> true ->
ejabberd_odbc:sql_query( ejabberd_odbc:sql_query(
LServer, LServer,
"select reltuples from pg_class " "select reltuples from pg_class where oid = 'users'::regclass::oid");
"where oid = 'users'::regclass::oid"); _ ->
ejabberd_odbc:sql_query(
LServer,
"select count(*) from users")
end;
_ -> _ ->
ejabberd_odbc:sql_query( ejabberd_odbc:sql_query(
LServer, LServer,