On 30.12.2016 06:55, Haribabu Kommi wrote:
Fujitsu was interested in developing a columnar storage extension with
changes the server backend.
We in PostgresPRO are also very interested in developing vertical
storage (VS) for Postgres.
And after considering many alternatives, we came to the conclusion that
approach based on representing columnar store as access method (index)
is the most promising one.
It allows to:
1. Implement VS as extension without affecting Postgres core.
2. Have both ROS and WOS.
3. Create multiple projections (as in Vertica).
4. Optimize insert speed by support batch inserts and use flexible
recovery model for VS.
So it is very similar with your approach. But there are few differences:
1. Our intention is to completely eliminate changes in Postgres core.
Yes, it is a mix of both index and table access methods. The current
of Vertical clustered index needs both access methods, because of this
But I still do not completely understand why it is not possible to use
VS in index only scans without any changes and standard Postgres executor?
Why it is not possible to rely on standard rules of applying indexes in
Postgres optimizer based on costs provided by our AM implementation?
we used both access methods.
2. You are accessing VS pages through Postgres buffer manager. It
certainly have a lot of advantages. First of all it significantly
simplifies implementation of VS and allows to reuse Postgres cache and
But is all leads to some limitation:
- For VS it is preferable to have larger pages (in Vertica size of page
can be several megabytes).
- VS is optimized for sequential access, so caching pages in buffer
manager is no needed and can only cause leaching of other useful pages
- It makes it not possible to implement in-memory version of VS.
- Access to buffer manager adds extra synchronization overhead which
becomes noticeable at MPP systems.
So I wonder if you have considered approach with VS specific
implementation of storage layer?
3. To take all advantages of vertical model, we should provide vector
Without it columnar store can only reduce amount of fetched data by
selective fetch of accessed columns and better compression of them.
But this is what existed cstore_fdw extension for Postgres also does.
We are going to use executor hooks or custom nodes to implement vector
operations for some nodes (filter, grand aggregate, aggregation with
Something similar with
What is your vision of optimizing executor to work with VS?
4. How do you consider adding parallelism support to VS? Should it be
handled inside VS implementation? Or should we use standard Postgres
parallel execution (parallel index-only scan)?
Thanks in advance,
The columnar store is implemented as an extension using index access
This can be easily enhanced with pluggable storage methods once they
A new index method (VCI) is added to create columnar index on the table.
The following is the basic design idea of the columnar extension,
This has the on-disk columnar representation. So, even after crash,
the columnar format is recovered to the state when it was crashed.
To provide performance benefit for both read and write operations,
the data is stored in two formats
1) write optimized storage (WOS)
2) read optimized storage (ROS).
This is useful for the users where there is a great chance of data
that is newly added instead of the old data.
write optimized storage is the data of all columns that are part of
stored in a row wise format. All the newly added data is stored in WOS
relation with xmin/xmax information also. If user wants to
newly added data, it doesn't affect the performance much compared to
deleting the data from columnar storage.
The tuples which don't have multiple copies or frozen data will be moved
from WOS to ROS periodically by the background worker process or autovauum
process. Every column data is stored separately in it's relation file.
is no transaction information is present in ROS. The data in ROS can be
referred with tuple ID.
In this approach, the column data is present in both heap and columnar
This is the place, where all the column data is stored in columnar format.
The data from WOS to ROS is converted by background workers
on the tuple visibility check. Whenever the tuple is frozen and it
from WOS to ROS.
The Data in ROS is stored in extents. One extent contains of 262,144
of fixed number of records in an extent it is easy to map the heap
record to the columnar
record with TID to CRID map.
The insert operation is just like inserting a data into an index.
Because of two storage formats, during the select operation, the data
is converted into Local ROS for the statement to be executed. The
cost depends upon the number of tuples present in the WOS file. This
may add some performance overhead for select statements. The life of
ROS is till the end of query context.
During the delete operation, whenever the data is deleted in heap at
time the data in WOS file is marked as deleted similar like heap. But
if the data is already migrated from WOS to ROS, then we will maintain
delete vector to store the details of tuple id, transaction
information and etc.
During the data read from ROS file, it is verified against delete
confirms whether the record is visible or not? All the delete vectors
data is applied to ROS periodically.
More details of internal relations and their usage is available in the
Still it needs more updates to explain full details of the columnar
The concept of Vertical clustered index columnar extension is from
Fujitsu Labs, Japan.
Following is the brief schedule of patches that are required
for a better performing columnar store.
1. Minimal server changes (new relkind "CSTORE" option)
2. Base storage patch
3. Support for moving data from WOS to ROS
4. Local ROS support
5. Custom scan support to read the data from ROS and Local ROS
6. Background worker support for data movement
7. Expression state support in VCI
8. Aggregation support in VCI
9. Pg_dump support for the new type of relations
10. psql \d command support for CSTORE relations
11. Parallelism support
12. Compression support
13. In-memory support with dynamic shared memory
Currently I attached only patches for 1 and 2. These will provide the
basic changes that are required in PostgreSQL core to the extension
I have to rebase/rewrite the rest of the patches to the latest master,
and share them with community.
Any Comments on the approach?
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company