Last active
January 2, 2022 21:56
-
-
Save garystafford/ed4d9a129a18355f51637533f8cab7a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- beeline or hive | |
-- beeline connect | |
!connect jdbc:hive2://localhost:10000/default | |
SHOW DATABASES; | |
DESCRIBE DATABASE moma_mor; | |
USE moma_cow;SHOW TABLES; | |
USE moma_mor;SHOW TABLES; | |
USE moma_mor;DESCRIBE artworks_ro; | |
MSCK REPAIR TABLE moma_mor.artworks_ro; | |
SHOW PARTITIONS moma_mor.artworks_ro; | |
ANALYZE TABLE moma_mor.artists_rt COMPUTE STATISTICS; | |
DESCRIBE EXTENDED moma_mor.artists_rt; | |
-- test query performance without caching | |
set hive.query.results.cache.enabled=false; | |
-- 100 rows selected (1.394 seconds) <- read-optimized vs. real-time table | |
SELECT * FROM moma_mor.artworks_ro WHERE department='Prints & Illustrated Books' LIMIT 100; | |
-- 100 rows selected (2.371 seconds) | |
SELECT * FROM moma_mor.artworks_rt WHERE department='Prints & Illustrated Books' LIMIT 100; | |
-- 10 rows selected (0.719 seconds) <- read-optimized vs. real-time table, classification is partitioned | |
SELECT * FROM moma_mor.artworks_ro WHERE classification='Print' LIMIT 10; | |
-- 10 rows selected (1.482 seconds) | |
SELECT * FROM moma_mor.artworks_rt WHERE classification='Print' LIMIT 10; | |
EXPLAIN EXTENDED SELECT * FROM moma_mor.artworks_rt WHERE artwork_id=128447 AND classification='Print'; | |
-- 1 row selected (14.126 seconds) <- read-optimized vs. real-time table | |
SELECT * FROM moma_mor.artworks_ro WHERE artwork_id=128447; | |
-- 1 row selected (32.877 seconds) | |
SELECT * FROM moma_mor.artworks_rt WHERE artwork_id=128447; | |
-- 1 row selected (1.491 seconds) <- classification is partitioned | |
SELECT * FROM moma_mor.artworks_rt WHERE artwork_id=128447 AND classification='Print'; | |
-- 84 rows selected (8.618 seconds) | |
SELECT artworks.title AS title, | |
artworks.`date` AS created, | |
artworks.name AS artist, | |
artists.nationality AS nationality, | |
artworks.classification AS classification | |
FROM moma_cow.artworks artworks | |
JOIN moma_cow.artists artists ON (artworks.artist_id = artists.artist_id) | |
WHERE artworks.artist_id = 4609 | |
AND nationality = 'Spanish' | |
AND classification = 'Print' | |
AND artworks.`date` IS NOT NULL | |
ORDER BY created, title; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment