the "rowid" column
What is actual function of the special column 'rowid'?
The column looks like a positional index of a table as often seen in other databases.
I did a test. With the table schema and 172M-row data set, the response time of query
select medallion from trips where rowid = 9999999;
and query
select hack_license from trips where medallion = '14F326693541402C4D10579EA55BF69B' limit 1;
are pretty close (took ~1 sec).
I had expected the first query to be much faster, because the rowid 9999999 might be used to directly fetch the value of a column from a data file (vs. loading all values of the column into memory) but it seems not. Correct?
My point of this test is if the rowid can be used to random access a data file and every INSERT of a row can return rowid of the row to mapdsql, by augmenting mapdsql with some SQL parsing functions and a key-value store, it is possible to add "indexing" function to mapd without significant changes to mapd server core...
Yes, the query using the rowid should execute in O(1). Not sure about the behavior you see, the first one should be basically instant. Does the first one take one second the second time you run it?
The first query took only 0.04s on 2nd+ time. It took ~1s at the first time. I thought seeking file to a specific position and read few KBs of data should take much less than one second even at the first time.
Interesting is, regardless if system file buffer/cache is cleared or not before starting mapd-server, the query always take 1s on the first time. That means file I/O is not the primary contribution to the latency. I guess, on the first time mapd-server needs some time to build up some hash table...
This time is likely the time to build the in memory Dictionaries for TEXT columns. Do you have a few TEXT ENCODING DICT columns in the schema?
No, there are no hash table tricks involved. We generate native code and run the query as usual. The only "cheating" is that we tell the generated code to start at the position specified by the rowid filter and only process one row. You can check for yourself that, if you add an additional filter which doesn't pass, it works correctly and it's just as fast once the data is in memory.
This time is likely the time to build the in memory Dictionaries for TEXT columns. Do you have a few TEXT ENCODING DICT columns in the schema?
Yes. But the query only involves one column. I thought values of that column should have been encoded when they were inserted.
it works correctly and it's just as fast once the data is in memory.
Perhaps i came from old world and still care about scenarios where data is most likely not in memory on the first query :)
They are. But dictionaries are loaded eagerly (before any query runs) as far as I know. This is one of the choices which doesn't fit low memory scenarios too well. Maybe we'll change it at some point.
The encoding has already occurred on insert. What is happening currently (we are currently working on mitigating this) is that on the first query to a table all the columns that have dictionary encoding are having the dictionaries structures instantiated in memory regardless of the columns being touched
We can't possibly chase all objectives at the same time. Currently we're focused on steady state behavior for workloads which fit in memory. I'm sure we'll want to improve the warm-up at some point too, but it's of lower priority than steady state.
How does mapd trim outdated data currently? If it doesn't, data will keep accumulated, which means at some point users need to start constantly adding memory to maintain the steady state?
A table can be capped with a WITH clause on the CREATE, see max_rows
https://www.mapd.com/docs/latest/mapd-core-guide/tables/#create-table
The oldest data will be removed when more data arrives and crosses the max_row threshold
A cap for the number of rows in the table can be specified at table creation time through the max_rows parameter. Least recently inserted rows are removed once that limit is hit.
Yes, if no cap is specified then more resources need to be added. "Keep data forever" is not a valid data retention policy; it requires infinite resources eventually.
Cap on row count is good. For some applications with dynamic data injection rates, cap on TTL seems more reasonable.
As long as the data is imported roughly in time order and the cap is not tiny, the results should be very similar. I don't think variable (if that's what you mean by dynamic) data injection rate makes a difference, it's all about the order.
AFAIE, oftentimes customers require data to be retained for a month or a year. Data time frame directly affects (dashboard and analytic) application design. For example, a line chart will look odd if few days of old (variable-rate) data is eliminated from a row based cap when the days are within required retaining period.
To them (and me), cap on row counts seem not as intuitive as on TTL. However, what to cap on seems policy based and not an issue, so i'm closing this issue.
Yes, we could drop data quite easily based on TTL thanks to the metadata we store in the fragments. Not a bad idea to add this policy.
@asuhan
They are. But dictionaries are loaded eagerly (before any query runs) as far as I know. This is one of the choices which doesn't fit low memory scenarios too well. Maybe we'll change it at some point.
Regarding the 1 sec latency, afterward i found 0.6 sec of it might come from warm-up of the parser. Any query, valid or invalid, right after mapd-server starts will amortize the latency. So, loading the dictionaries actually does not take that long as observed previously.