Failed to run the cardinality estimation query
I just found that with single GROUP BY column MapD is much much faster than Clickhouse. For example, on the same host, the following query took CH 50+ seconds but took MapD <1 sec to finish, once after the data set (172M rows) was "warmed up" in memory. (really amazing!!)
select count() from (select count() from trips group by medallion); select count() from (select count() from trips group by hack_license);
However, the following query with multiple columns in GROUP BY clause
select count() from (select count() from trips group by medallion,hack_license);
took CH 120 secs to finish but caused MapD to fail with the following error:
Exception: Failed to run the cardinality estimation query: Query couldn't keep the entire working set of columns in GPU memory
(my VM has ~4GB free memory before running the query)
What should i do to make the query above work?
GROUP BY with multiple columns/expressions is very common seen with database applications for rolling up data.
Here is DDL statement of the table trips:
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);
Also, with single column in GROUP BY clause, if the query contains a WHERE clause, the response time became either significantly longer or unpredictable.
For example, on the first execution of this query:
select count(*) from (select max(trip_distance) from trips where trip_time_in_secs > 99 group by medallion);
it returned an error: Exception: Query couldn't keep the entire working set of columns in GPU memory
On the 2nd execution, it returned a numerical result in 6.5 secs. On the 3rd execution, it returned the error again. On the 4th execution, it returned the numerical result in 5.6 secs. On the 5rd execution, it returned the error again. ...(repeated)...
What is the hardware you are executing on.
Can you share your log.
I suspect you are very tight on GPU memory and having issues there.
What is the size of the table you are trying to work on?
The VM is Ubuntu 16.04 hosted on a i5-3570K server with 8GB memory but without GPU. After mapd-server is launched, the query has >4GB free memory to run, i'm sure. The data set contains 172M rows of NY taxi data.
@dwayneberry moved your log to a file for readability
When the query could execute and return a value (13714), system free memory always showed 3+ GB free memory, so CPU memory seemed not an issue...
First of all it's bizarre to see GPU-related exceptions on a system which doesn't have any GPUs. Can you track down the source of exception with catch throw in gdb? You're going to see some Thrift transport exceptions, but once you're past them you'll find the source of the OutOfMemory exception.
I think you're seeing some sort of fixed memory overhead again. Since we mainly run on systems with a lot of memory and bigger datasets, we don't have much experience with this type of behaviors. It's not terribly hard to fix, but it requires some focused effort.
To check if the failures reported in my previous comments relate with memory capacity, i did a quick test by creating another table 'trip1' and import only 14M of original 172M rows, then redid the same queries.
This time every query work perfectly (<0.1s!) once data was warmed up. (>6s when cold)
So previous failure were indeed due to memory constraint of my VM. However, one thing i'm still curious is why a query like "select max(trip_distance) from trips group by medallion,hack_license)" on 172M rows would need 3+ GB memory when each row of the two columns (medallion and hack_license) just need 2+2 bytes.
Another thing still intriguing is why the query "select max(trip_distance) from trips where trip_time_in_secs > 99 group by medallion" on 172M rows can alternate between success and failure when it was executed repeatedly. If there is memory constrain, it should have failed always.
I'm sure if i increase my VM memory to 30G (i wish i could) all these issues will be gone, so i'm closing this issue. Thanks again for the investigation.