heavydb icon indicating copy to clipboard operation
heavydb copied to clipboard

how much memory is needed for this query?

Open fleapapa opened this issue 9 years ago • 5 comments

I tried to calculate a histogram of trip time of a 170M-row NY taxi trip data.

My VM has ~5.5 GB free memory right before running the query.

The query is

select floor(trip_time_in_secs/600) as bin, count(*) as cnt from trips where trip_time_in_secs >= 60 group by bin;

The result is

Exception: Failed to run the cardinality estimation query: Query couldn't keep the entire working set of columns in GPU memory

(Oddly, top command showed very few used memory during 30-sec execution of the query)

I know if my VM can have 100 more GBs of memory the result may be different.

What i would like to know is how much memory approximately will be sufficient for this single-column query for the 170M rows?

fleapapa avatar Sep 21 '17 15:09 fleapapa

Please include your logs and schemas with your questions, makes it easier to have reasonable answers

dwayneberry avatar Sep 21 '17 16:09 dwayneberry

Schema

CREATE TABLE trips ( medallion TEXT ENCODING DICT, hack_license TEXT ENCODING DICT, vendor_id TEXT ENCODING DICT, rate_code_id SMALLINT, store_and_fwd_flag TEXT ENCODING DICT, pickup_datetime TIMESTAMP, dropoff_datetime TIMESTAMP, passenger_count SMALLINT, trip_time_in_secs INTEGER, trip_distance DECIMAL(14,2), pickup_longitude DECIMAL(14,2), pickup_latitude DECIMAL(14,2), dropoff_longitude DECIMAL(14,2), dropoff_latitude DECIMAL(14,2) ) WITH (FRAGMENT_SIZE=75000000);

Log

I0921 00:32:17.127301 4145 MapDServer.cpp:602] MapD started with data directory at '/mnt/trip/mapd/data' I0921 00:32:17.127512 4145 MapDServer.cpp:609] Watchdog is set to 1 I0921 00:32:17.127524 4145 MapDServer.cpp:631] cuda block size 0 I0921 00:32:17.127532 4145 MapDServer.cpp:632] cuda grid size 0 I0921 00:32:17.127539 4145 MapDServer.cpp:633] calcite JVM max memory 1024 I0921 00:32:17.127547 4145 MapDServer.cpp:634] MapD Server Port 9091 I0921 00:32:17.127554 4145 MapDServer.cpp:635] MapD Calcite Port 9093 I0921 00:32:17.127580 4145 MapDHandler.cpp:162] MapD Server 3.2.1-20170826-327e7ee E0921 00:32:17.127591 4145 MapDHandler.cpp:169] This build isn't CUDA enabled, will run on CPU I0921 00:32:17.127826 4145 DataMgr.cpp:120] cpuSlabSize is 102.4M I0921 00:32:17.127910 4145 FileMgr.cpp:116] Read table metadata, Epoch is 0 for table data at '/mnt/trip/mapd/data/mapd_data/table_0_0/' I0921 00:32:17.128021 4145 Calcite.cpp:156] Creating Calcite Handler, Calcite Port is 9093 base data dir is /mnt/trip/mapd/data I0921 00:32:17.128033 4145 Calcite.cpp:95] Running calcite server as a daemon I0921 00:32:17.339471 4145 Calcite.cpp:124] Calcite server start took 200 ms I0921 00:32:17.339509 4145 Calcite.cpp:125] ping took 10 ms I0921 00:32:17.344010 4145 Calcite.cpp:281] [{"name":"Tan","ret":"double","args":["double"]},{"name":"Truncate__","ret":"float","args":["float","i32"]},{"name":"ln","ret":"double","args":["double"]},{"name":"Floor__2","ret":"i32","args":["i32"]},{"name":"Floor__3","ret":"i64","args":["i64"]},{"name":"rect_pixel_bin","ret":"float","args":["float","float","float","i32","i32"]},{"name":"Floor__1","ret":"i16","args":["i16"]},{"name":"degrees","ret":"double","args":["double"]},{"name":"approx_distance_in_meters","ret":"double","args":["float","float","float","float"]},{"name":"Ceil__2","ret":"i32","args":["i32"]},{"name":"Ceil__1","ret":"i16","args":["i16"]},{"name":"Ceil__3","ret":"i64","args":["i64"]},{"name":"Log10","ret":"double","args":["double"]},{"name":"Log","ret":"double","args":["double"]},{"name":"distance_in_meters","ret":"double","args":["double","double","double","double"]},{"name":"round_to_digit","ret":"double","args":["double","i32"]},{"name":"Atan2","ret":"double","args":["double","double"]},{"name":"Acos","ret":"double","args":["double"]},{"name":"Sin","ret":"double","args":["double"]},{"name":"Ceil","ret":"double","args":["double"]},{"name":"distance_in_meters__","ret":"double","args":["float","float","float","float"]},{"name":"Floor__","ret":"float","args":["float"]},{"name":"Truncate","ret":"double","args":["double","i32"]},{"name":"radians","ret":"double","args":["double"]},{"name":"Ceil__","ret":"float","args":["float"]},{"name":"ln__","ret":"double","args":["float"]},{"name":"reg_hex_vert_pixel_bin_y","ret":"float","args":["float","float","float","float","float","float","float","float","float","float","i32","i32"]},{"name":"reg_hex_vert_pixel_bin_x","ret":"float","args":["float","float","float","float","float","float","float","float","float","float","i32","i32"]},{"name":"Round","ret":"double","args":["double"]},{"name":"power","ret":"double","args":["double","double"]},{"name":"conv_4326_900913_x","ret":"double","args":["double"]},{"name":"reg_hex_horiz_pixel_bin_y","ret":"float","args":["float","float","float","float","float","float","float","float","float","float","i32","i32"]},{"name":"conv_4326_900913_y","ret":"double","args":["double"]},{"name":"Atan","ret":"double","args":["double"]},{"name":"reg_hex_horiz_pixel_bin_x","ret":"float","args":["float","float","float","float","float","float","float","float","float","float","i32","i32"]},{"name":"Floor","ret":"double","args":["double"]},{"name":"Truncate__1","ret":"i16","args":["i16","i32"]},{"name":"Truncate__2","ret":"i32","args":["i32","i32"]},{"name":"Truncate__3","ret":"i64","args":["i64","i32"]},{"name":"Cos","ret":"double","args":["double"]},{"name":"Log__","ret":"double","args":["float"]},{"name":"Log10__","ret":"double","args":["float"]},{"name":"Asin","ret":"double","args":["double"]},{"name":"Cot","ret":"double","args":["double"]},{"name":"Tan__","ret":"double","args":["float"]},{"name":"rect_pixel_bin_x","ret":"float","args":["float","float","float","float","float","i32"]},{"name":"rect_pixel_bin_y","ret":"float","args":["float","float","float","float","float","i32"]},{"name":"pi","ret":"double","args":[]},{"name":"Exp","ret":"double","args":["double"]}] E0921 00:32:17.344488 4145 MapDHandler.cpp:201] No GPUs detected, falling back to CPU mode I0921 00:32:17.344525 4145 MapDHandler.cpp:210] Started in CPU mode I0921 00:32:44.557510 4173 MapDHandler.cpp:359] User mapd connected to database mapd I0921 00:32:44.558357 4173 MapDHandler.cpp:555] sql_execute :78pty9J53LYA7aW10qSPAIaXTgawrJJP:query_str:select floor(trip_time_in_secs/600) as bin, count() as cnt from trips where trip_time_in_secs >= 60 group by bin; I0921 00:32:44.559092 4173 Calcite.cpp:247] User mapd catalog mapd sql 'select floor(trip_time_in_secs/600) as bin, count() as cnt from trips where trip_time_in_secs >= 60 group by bin;' I0921 00:32:45.149942 4172 FileMgr.cpp:116] Read table metadata, Epoch is 310 for table data at '/mnt/trip/mapd/data/mapd_data/table_1_1/' I0921 00:32:45.405473 4173 Calcite.cpp:260] Time in Thrift 13 (ms), Time in Java Calcite server 833 (ms) I0921 00:32:45.425710 4181 BufferMgr.cpp:266] ALLOCATION slab of 209715 pages (107374080B) created in 0 ms CPU_MGR:0 E0921 00:32:45.807050 4173 MapDHandler.cpp:2810] Exception: Failed to run the cardinality estimation query: Query couldn't keep the entire working set of columns in GPU memory I0921 00:32:45.807631 4173 MapDHandler.cpp:369] User mapd disconnected from database mapd

fleapapa avatar Sep 21 '17 16:09 fleapapa

Your VM is allowing MapD only 102M to work

I0921 00:32:17.127826 4145 DataMgr.cpp:120] cpuSlabSize is 102.4M

dwayneberry avatar Sep 21 '17 16:09 dwayneberry

You would need approximately 170M x 4bytes (integer) + some wiggle room for a query like this

dwayneberry avatar Sep 21 '17 16:09 dwayneberry

Just found my command line has one digit truncated. That's why the 102M came from :) Sorry for the ignorance. Closing this issue.

fleapapa avatar Sep 21 '17 16:09 fleapapa