Query on information-schema
-
Hi There,
A faster version of this query :
$identifier = $wpdb->get_var(“SELECT COLUMN_NAME
FROM information_schema.COLUMNS
WHERE
TABLE_NAME = ‘$wpdb->users’
AND COLUMN_NAME = ‘identifier'”);
Can be obtained by adding condition on TABLE_SCHEMA column in thi way :$identifier = $wpdb->get_var(“SELECT COLUMN_NAME
FROM information_schema.COLUMNS
WHERE
TABLE_NAME = ‘$wpdb->users’
AND TABLE_SCHEMA=’$wpdb->dbname’
AND COLUMN_NAME = ‘identifier'”);This is because, when there is a huge number of databases and tables, the access to information_schema views requires to specify the TABLE_SCHEMA in the WHERE condition in order to have a better query’s execution time.
Thanks,
Stofa.
The topic ‘Query on information-schema’ is closed to new replies.