Live data from Hacker News

Vectorization in OLAP Databases

aneesh.mataroa.blog

11–19 of 19 posts

Re: Vectorization in OLAP Databases

#11
post #6

Earlier quoted context omitted.

Came here to post this, fantastic paper and probably the most comprehensive thing on the internet available about this Something else I've taken away from research about columnar and vectorized databases: there doesn't seem a good reason why they aren't fit for OLTP workloads Analytics from SaaS/line-of-business apps shows about a 90/10 read/write ratio for CRUD apps. Pavlo et al. have a solid paper on an HTAP databa…

For scan heavy apps columnstores will be much much faster. For simple CRUD apps that just want to read/write a few rows at a time (with high concurrency) they have a number of inefficiencies vs a rowstore. - Columnstore often don't support indexing at all (or have weak support for it). This means a scan is needed to find any row (with min/max or segment elimination to avoid opening up files with no matching rows at a…

Really interesting, going to have a look at that paper -- thanks for sharing your insight

Let me ask this: if you have something like a GraphQL API, which often does sparse column selection from multiple different tables, would that also be a good fit for columnar database?

In most GraphQL queries, you're grabbing a portion of the fields from one or more tables, IE something like:

    query JoesCompletedTodos {
        users(where: { name: { _eq: "Joe" } }) {
            id
            name
            todos(where: { completed: { _eq: true } }) {
                text
            }
        }
    }
Where this will get translated to something along the lines of

    SELECT users.id, users.name, json_arrayagg(todos) FROM users
    INNER JOIN todos ON todos.user_id = users.id
    WHERE users.name = 'Joe' AND todos.completed = true
    GROUP BY users.id, users.name
Many times you'll see queries spanning 3-4 relation levels deep, plucking something like 2-6 columns from each table.

Curious how well a columnar DB would do with something like this?

Also, on this point:

  > "Most columnstores don't use compression schemes that are incremental.  To grab a single row the columnstore likely decompresses many adjacent rows (could be millions of rows - depends on the particular columnstore)."
I think this is something that could be avoided if the data were in IE, Arrow, and you used Arrow Flight/FlightSQL as the transport mechanism, right? But this isn't my area of expertise, for sure.

Re: Vectorization in OLAP Databases

#12
post #6

Earlier quoted context omitted.

Came here to post this, fantastic paper and probably the most comprehensive thing on the internet available about this Something else I've taken away from research about columnar and vectorized databases: there doesn't seem a good reason why they aren't fit for OLTP workloads Analytics from SaaS/line-of-business apps shows about a 90/10 read/write ratio for CRUD apps. Pavlo et al. have a solid paper on an HTAP databa…

For scan heavy apps columnstores will be much much faster. For simple CRUD apps that just want to read/write a few rows at a time (with high concurrency) they have a number of inefficiencies vs a rowstore. - Columnstore often don't support indexing at all (or have weak support for it). This means a scan is needed to find any row (with min/max or segment elimination to avoid opening up files with no matching rows at a…

Also I just noticed that you used the TPC-C benchmark here

Have you considered re-benchmarking with TPC-E? It's the updated version of the OLTP test that more accurately represents these sorts of apps:

  > "In February 2007, the new TPC-E benchmark [7] became a TPC standard. It is designed to be a more realistic OLTP benchmark than TPC-C, e.g., incorporating realistic data skews and referential integrity constraints."


  > "We find that (i) TPC-E is more read intensive with a 9.7:1 I/O read to write ratio, while TPC-C sees a 1.9:1 read-to-write ratio; and (ii) although TPC-E uses pseudo-realistic data, TPC-E’s I/O access pattern is as random as TPC-C."
It's a difference between a 10/1 read/write ratio, and a 2/1 read/write ratio. I've never worked on a line-of-business/SaaS app with a ratio lower than 80% reads FWIW.

https://www.tpc.org/tpce/default5.asp

http://www.cs.cmu.edu/~chensm/papers/TPCE-sigmod-record10.pd...

Re: Vectorization in OLAP Databases

#13
post #4

Isn't the typical big data sql task IO bound? Vectorization only works when you have a table stored in an optimized columnar format and compute an run a function over a column or to combine multiple columns. The moment you throw in group bys or windows the data turns into rows that you read from a hash table or after a sort - at which point you lose all opportunities of vectorization. Since group bys break vectorizat…

In a well-designed system, you will typically be limited by effective bandwidth, often memory bandwidth or efficient use thereof which is an area where vectorization can help. Modern servers have tremendous storage bandwidth if you have an I/O scheduler capable of using it. Some newer database engines explicitly reject the assumption that storage throughput is precious as a design constraint, since it has become much less true over time due to advances in hardware.

Use of page layouts highly-optimized for vectorized evaluation is common now even if the implementation isn't vectorized. You lose nothing on modern hardware (they are good layouts regardless) and it allows you to easily do vector optimizations later. As a semantic distinction, columnar and vector layouts are organized differently and optimize for somewhat different things even though they have superficially similar appearance. Classic DSM-style columnar is largely obsolete.

Vectorization, first and foremost, is about optimizing selection operations in a database, but it can provide assists in other areas like joins, sorts, and aggregates. Most queries are a composed from these primitives, so many parts of the query plan may benefit. As a heuristic, operations that GPU databases excel at are the same kinds of operations that benefit from vectorization.

Obviously you can't just throw vectorization at an arbitrary database and expect major benefits, they need to be intentionally designed for it.

Re: Vectorization in OLAP Databases

#14

Earlier quoted context omitted.

For scan heavy apps columnstores will be much much faster. For simple CRUD apps that just want to read/write a few rows at a time (with high concurrency) they have a number of inefficiencies vs a rowstore. - Columnstore often don't support indexing at all (or have weak support for it). This means a scan is needed to find any row (with min/max or segment elimination to avoid opening up files with no matching rows at a…

Also I just noticed that you used the TPC-C benchmark here Have you considered re-benchmarking with TPC-E? It's the updated version of the OLTP test that more accurately represents these sorts of apps: > "In February 2007, the new TPC-E benchmark [7] became a TPC standard. It is designed to be a more realistic OLTP benchmark than TPC-C, e.g., incorporating realistic data skews and referential integrity constraints."…

Yeah, TPC-E is a better (more advanced) OLTP benchmark. TPC-C is trivially scalable by sharding on warehouse id everywhere. The problem with TPC-E is not many companies publish (official or unofficial) results for it, so its not as useful when comparing systems, which is what we were after in our blog post.

Re: Vectorization in OLAP Databases

#15

Earlier quoted context omitted.

Also I just noticed that you used the TPC-C benchmark here Have you considered re-benchmarking with TPC-E? It's the updated version of the OLTP test that more accurately represents these sorts of apps: > "In February 2007, the new TPC-E benchmark [7] became a TPC standard. It is designed to be a more realistic OLTP benchmark than TPC-C, e.g., incorporating realistic data skews and referential integrity constraints."…

Yeah, TPC-E is a better (more advanced) OLTP benchmark. TPC-C is trivially scalable by sharding on warehouse id everywhere. The problem with TPC-E is not many companies publish (official or unofficial) results for it, so its not as useful when comparing systems, which is what we were after in our blog post.

  > The problem with TPC-E is not many companies publish (official or unofficial) results for it, so its not as useful when comparing systems, which is what we were after in our blog post.
Oh, yeah this makes a lot of sense

Re: Vectorization in OLAP Databases

#16

Earlier quoted context omitted.

For scan heavy apps columnstores will be much much faster. For simple CRUD apps that just want to read/write a few rows at a time (with high concurrency) they have a number of inefficiencies vs a rowstore. - Columnstore often don't support indexing at all (or have weak support for it). This means a scan is needed to find any row (with min/max or segment elimination to avoid opening up files with no matching rows at a…

Really interesting, going to have a look at that paper -- thanks for sharing your insight Let me ask this: if you have something like a GraphQL API, which often does sparse column selection from multiple different tables, would that also be a good fit for columnar database? In most GraphQL queries, you're grabbing a portion of the fields from one or more tables, IE something like: query JoesCompletedTodos { users(whe…

Filters like this one:

    WHERE users.name = 'Joe' AND todos.completed = true
Have most of the problems I mentioned above unless "many" rows match the filter. Lack of ability to seek to specific rows in the data hurts.

RE: Arrow.. I haven't read too much about the compression scheme(s) it uses. If it only does dictionary compression, that is reasonable easy to make incremental, so its possible Arrow doesn't have that specific problem.

Re: Vectorization in OLAP Databases

#18
post #4

Isn't the typical big data sql task IO bound? Vectorization only works when you have a table stored in an optimized columnar format and compute an run a function over a column or to combine multiple columns. The moment you throw in group bys or windows the data turns into rows that you read from a hash table or after a sort - at which point you lose all opportunities of vectorization. Since group bys break vectorizat…

I can't seem to understand why vectorization wouldn't help, say if you read after a sort. Irrespective of whether it fits in memory, or you perform some sort of an external sort, any operation that you want to perform on top of that sorted vector, be it an aggregation to reduce it, or an arithmetic operation with another column, you could still leverage vectorization and would end up using fewer CPU cycles, no?

Re: Vectorization in OLAP Databases

#19

> A recent trend It's not at all a recent trend, it goes back at least as far as the early 2000s. Also, the obvious next step from thinking about processing a few tuples together, is transposing your view of DB tables all the way, to consider _columns_ rather than _tuples_. This makes a lot of sense when you're processing analytic queries rather than transactions, which typically modify individual tuples. And _that_…

Fair point about the "recentness". I guess it seemed recent to me since I learned about it only a few months back :)

Also, yes, 100%. Columnar storage fits well with vectorized execution! Thanks for sharing

Post reply on HN