0% found this document useful (0 votes)
35 views

Lab10 Caching

The document demonstrates the effect of warehouse size, results caching, and filters on query performance against the TPCH_SF1000.CUSTOMER table. With a small warehouse, full table scans take minutes but metadata queries are fast. Increasing the warehouse size to large reduces scan times to seconds. Turning off caching or reducing the warehouse size increases query times, while adding filters improves performance of targeted scans.

Uploaded by

vr.sf99
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Lab10 Caching

The document demonstrates the effect of warehouse size, results caching, and filters on query performance against the TPCH_SF1000.CUSTOMER table. With a small warehouse, full table scans take minutes but metadata queries are fast. Increasing the warehouse size to large reduces scan times to seconds. Turning off caching or reducing the warehouse size increases query times, while adding filters improves performance of targeted scans.

Uploaded by

vr.sf99
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

// Run with X-Small or Small Warehouse

// Run below queries and observe query profile

// Query is fetching results from Storage layer(Remote Disk)


SELECT * FROM TPCH_SF1000.CUSTOMER; -- 2min 20sec

// Fetching METADATA info is very fast, look at query profile


SELECT COUNT(*) FROM TPCH_SF1000.CUSTOMER; -- 70ms
SELECT MIN(C_CUSTKEY) FROM TPCH_SF1000.CUSTOMER; -- 68 ms
SELECT MAX(C_CUSTKEY) FROM TPCH_SF1000.CUSTOMER; -- 64 ms

// Run the same query again and observe time taken and query profile
SELECT * FROM TPCH_SF1000.CUSTOMER; -- 113 ms

// Try to fetch same data by changing queries little bit and observe query profile
SELECT C_CUSTKEY, C_NAME, C_ACCTBAL, C_ADDRESS FROM TPCH_SF1000.CUSTOMER; -- 53 sec
SELECT C_CUSTKEY, C_ADDRESS FROM TPCH_SF1000.CUSTOMER; -- 36 sec
SELECT C_ADDRESS, C_CUSTKEY FROM TPCH_SF1000.CUSTOMER; -- 32 sec

// Try to fetch subset of data, with a filter


SELECT C_CUSTKEY, C_NAME, C_ACCTBAL, C_ADDRESS FROM TPCH_SF1000.CUSTOMER
WHERE C_NATIONKEY in (1,2); -- 9.9 sec

==================================================================
// Turn off Results Cache, Suspend the VW, run same queries and see query profile
ALTER SESSION SET USE_CACHED_RESULT = FALSE;

// First time, it will fetch the data from Remote Disk


SELECT * FROM TPCH_SF1000.CUSTOMER; -- 2min 19sec

// Run the same query again and observe time taken and query profile
SELECT * FROM TPCH_SF1000.CUSTOMER; -- 2 min 15sec

// Try to fetch same data by changing queries little bit and observe query profile
SELECT C_CUSTKEY, C_NAME, C_ACCTBAL, C_ADDRESS FROM TPCH_SF1000.CUSTOMER; -- 53sec
SELECT C_CUSTKEY, C_ADDRESS FROM TPCH_SF1000.CUSTOMER; -- 34sec
SELECT C_ADDRESS, C_CUSTKEY FROM TPCH_SF1000.CUSTOMER; -- 34sec

// Try to fetch subset of data, with a filter


SELECT C_CUSTKEY, C_NAME, C_ACCTBAL, C_ADDRESS FROM TPCH_SF1000.CUSTOMER
WHERE C_CUSTKEY < 200000; -- 750 ms

SELECT C_CUSTKEY, C_NAME, C_ACCTBAL, C_ADDRESS FROM TPCH_SF1000.CUSTOMER


WHERE C_NATIONKEY in (1,2,3,4,5); -- 12sec
==================================================================

// Increase VW size to L or XL, run same queries and see query profile

// First time, it will fetch the data from Remote Disk


SELECT * FROM TPCH_SF1000.CUSTOMER; -- 13 sec

// Run the same query again and observe time taken and query profile
SELECT * FROM TPCH_SF1000.CUSTOMER; -- 14 sec

// Try to fetch same data by changing queries little bit and observe query profile
SELECT C_CUSTKEY, C_NAME, C_ACCTBAL, C_ADDRESS FROM TPCH_SF1000.CUSTOMER; -- 4.8sec
SELECT C_CUSTKEY, C_ADDRESS FROM TPCH_SF1000.CUSTOMER; -- 7.9 sec
SELECT C_ADDRESS, C_CUSTKEY FROM TPCH_SF1000.CUSTOMER; -- 3.4 sec
// Try to fetch subset of data, with a filter
SELECT C_CUSTKEY, C_NAME, C_ACCTBAL, C_ADDRESS FROM TPCH_SF1000.CUSTOMER
WHERE C_CUSTKEY < 200000; -- 891

SELECT C_CUSTKEY, C_NAME, C_ACCTBAL, C_ADDRESS FROM TPCH_SF1000.CUSTOMER


WHERE C_NATIONKEY in (1,2,3,4,5); -- 1.6 sec
==================================================================

You might also like