Uploaded image for project: 'Apache Drill'
  1. Apache Drill
  2. DRILL-5972

Slow performance for query on INFORMATION_SCHEMA.TABLE

    Details

      Description

      A query like the following on INFORMATION_SCHEMA takes a long time to execute.

      select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE from INFORMATION_SCHEMA.`TABLES` WHERE TABLE_NAME LIKE '%' AND ( TABLE_SCHEMA = 'hive.default' ) ORDER BY TABLE_TYPE, TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME;

      Reason being we fetch table information for all schemas instead of just 'hive.default' schema.

      If we change the predicate like this, it executes very fast.

      select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE from INFORMATION_SCHEMA.`TABLES` WHERE ( TABLE_SCHEMA = 'hive.default' ) AND TABLE_NAME LIKE '%' ORDER BY TABLE_TYPE, TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME;

      The difference is in the order in which we evaluate the expressions in the predicate.
      In the first case, we first evaluate TABLE_NAME LIKE '%' and decide that it is inconclusive (since we do not know the schema). So, we go get all tables for all the schemas.

      In the second case, we first evaluate TABLE_SCHEMA = 'hive.default' and decide that we need to fetch only tables for that schema.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ppenumarthy Padma Penumarthy
                Reporter:
                ppenumarthy Padma Penumarthy
                Reviewer:
                Parth Chandra
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: