diff --git a/ChangeLog b/ChangeLog index 4ee67440e..6732f1003 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,9 @@ * src/mod_pubsub/mod_pubsub.erl: PEP notification bugfix + * src/odbc/odbc_queries.erl: User count performance improvements + (EJAB-239) + 2007-12-20 Badlop * src/msgs/zh.msg: Small update (thanks to Shelley Shyan) diff --git a/src/odbc/odbc_queries.erl b/src/odbc/odbc_queries.erl index 98e074b38..e4daefbb7 100644 --- a/src/odbc/odbc_queries.erl +++ b/src/odbc/odbc_queries.erl @@ -147,17 +147,26 @@ list_users(LServer, [{prefix, Prefix}, "limit ~w offset ~w ", [Prefix, Limit, Offset])). users_number(LServer) -> - case ejabberd_config:get_local_option( - {pgsql_users_number_estimate, LServer}) of + case element(1, ejabberd_config:get_local_option({odbc_server, 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 -> ejabberd_odbc:sql_query( - LServer, - "select reltuples from pg_class " - "where oid = 'users'::regclass::oid"); + LServer, + "select reltuples from pg_class where oid = 'users'::regclass::oid"); _ -> ejabberd_odbc:sql_query( - LServer, - "select count(*) from users") + LServer, + "select count(*) from users") + end; + _ -> + ejabberd_odbc:sql_query( + LServer, + "select count(*) from users") end. users_number(LServer, [{prefix, Prefix}]) when is_list(Prefix) ->