64
$\begingroup$

thanks a lot for your discussions on the original post.

following your suggestions, let me re-phrase a bit :

kdb is known for its efficiency, and such efficiency comes at a terrible price. However, with computational power so cheap this days, there must be a sweet spot where we can achieve a comparable efficiency of data manipulation, at a more reasonable cost.

For instance, if a KDB license cost a small shop $200K per year (I dont know how much it actually cost, do you know?), maybe there is a substitute solution: e.g., we pay 50K to build a decent cluster, storing all data onto a network file system, and parallelize all the data queries. This solution might not be as fast or as elegant as KDB, but it would be much more affordable and most important -- you take full control of it.

what do you think? is there anything like this?

$\endgroup$
4
  • 3
    $\begingroup$ I'm not sure what you mean. The main trick used by KDB is to store the data in columns instead of rows. This has the advantage that if one column is selected all the data can be read in one long read. This can also be done in Python. $\endgroup$
    – Bob Jansen
    Commented Apr 1, 2012 at 10:52
  • 4
    $\begingroup$ 1) Storing each tick as a separate record/row is neither sensible nor feasible (as you already mentioned). The most common approach is to split tick data by day and store days of data as plain arrays, either in files or in database LOBs. Such approach makes the amount of data perfectly manageable. 2) possible duplicate of What is the best data structure/implementation for representing a time series? $\endgroup$
    – wburzyns
    Commented Apr 1, 2012 at 18:50
  • 1
    $\begingroup$ The minimal 2-core setup of kdb+ is actually pretty reasonable: $25K per year including maintenance. $\endgroup$
    – user2303
    Commented Apr 19, 2013 at 1:53
  • 2
    $\begingroup$ artic could be an option (it's free software, build on top of MongoDB), but I haven't used it, so I cannot give you an opiniion on that: github.com/manahl/arctic $\endgroup$ Commented Jan 24, 2018 at 9:46

20 Answers 20

23
$\begingroup$

At discretelogics we just released a file format to store time series in flat files called "TeaFiles". In addition to raw data they can store the binary item layout and a description of the contents.

C#, C++, Python APIs are available open source, licensed under the GPL, see discretelogics.com/teafiles/

Using memory mapping, read performance reaches that of in-memory array processing for sequential usage of a file, as is the case for back testing.

The C# API at Codeplex holds micro benchmarks. Summing up a file with a single 8 byte double reaches 500 million operations per second on an older test machine. Using a Tick Item with int64 / double / int for Time/Price/Volume is 100 million operations.

$\endgroup$
9
  • 2
    $\begingroup$ +1 I like the idea. How do you handle cross-sectional time series? Will we be able to embed you visualization API into a custom app? $\endgroup$
    – SRKX
    Commented Apr 8, 2012 at 9:07
  • $\begingroup$ thank you! by cross-sectional time series you mean the analysis of several series like computing an index or stat arb, right? about embedding - our code base would allow embed-able components. we thought already about offering that. i take your question as valuable input for our product road map. at the moment our visualization tools TeaHouse/TeaShell are windows / XAML. our persistence layer is cross OS/app and we plan visualization on html5 architecture for the future. our decisions will be customer driven, so your vote counts. we are thankful for any feedback and inside into your needs. $\endgroup$ Commented Apr 8, 2012 at 11:58
  • 1
    $\begingroup$ Benchmarks about raw time series data access using TeaFiles are included in the C#/C++ sources, see teafiles.codeplex.com/wikipage?title=Benchmarks. A benchmark against HDFS would first need to specify what to measure. TeaFiles perform 1:1 to raw data structs in files, as they are nothing else + allow memory mapping. This is hardly to beat at first. Read ahead, prefetching allow going beyond in some situations. HDFS would be a layer above raw file storage and we have it on our roadmap to take simple file persistence to the next level. For management not for performance reasons tough. $\endgroup$ Commented Jan 23, 2013 at 0:06
  • 1
    $\begingroup$ A little late to the party here but the link in the answer is now dead. $\endgroup$
    – chollida
    Commented Jun 23, 2014 at 17:22
  • 1
    $\begingroup$ Awesome project! Thank you for making it open source. $\endgroup$
    – user5352
    Commented Dec 4, 2015 at 16:20
22
$\begingroup$

As of April 2014, the 32-bit version of kdb+ is now free to try.

This free version may not be used in production systems.

The only technical limitation vs. the 64-bit version is that you can only address up to 4GB of memory per process.

$\endgroup$
5
  • $\begingroup$ I was not aware of that, thanks a lot for this update, +1 $\endgroup$
    – Matt Wolf
    Commented May 20, 2014 at 7:39
  • 20
    $\begingroup$ It's not free as in free beer. You are restricted to using it for non-commercial purposes only. It's basically a trial. You answer makes it sound like it's open source which is not true. $\endgroup$
    – user5352
    Commented Dec 4, 2015 at 16:10
  • 2
    $\begingroup$ Not only is it not free, but as of 2019 it is time limited. From the licence: 1.4 Disabling Features. End User understands that the Kdb+ On Demand Software contains a feature which will automatically cause the Kdb+ On Demand Software to time-out six (6) months from the date of installation of the Kdb+ On Demand Software or such other date which Kx at its discretion identifies. Kx may at its discretion from time to time agree to extend use of the Kdb+ On Demand Software for a further six (6) months or such other period which Kx at its discretion identifies. $\endgroup$ Commented Dec 11, 2019 at 21:44
  • $\begingroup$ Kdb+ On Demand is different from the 32-bit version of kdb. On Demand provides fill 64-Bit version but requires internet connection and license that will time out. $\endgroup$
    – emc211
    Commented Jul 6, 2020 at 22:54
  • $\begingroup$ Maybe hobbes.readthedocs.io/en/latest ? $\endgroup$
    – reim
    Commented Nov 29, 2020 at 4:10
17
$\begingroup$

I don't like KDB+/q. For KDB+ experts, I am not picking a fight. The following is just my own understanding on KDB+ and TimeSeries Database. You're warmly welcome to correct me if anything wrong in your eyes :).

First of all, during my near one year's KDB+/q development experience, I never ever find a paper based benchmark result indicating KDB+/q significantly out performs other storage system in time. By storage system, I don't limit the scope to disk based RDBMS. So I don't know why everybody in quant finance is talking about KDB+ and impressed by its efficiency without data backing their points.

Second, I once talked with an Oracle Certificated DBA about KDB+. From my description, the first word he came up is an in-memory cache not even a full fledge database. Maybe he is right to some extent, isn't he?

Next is the so-called TimeSeries. More than one manager advocating KDB+ from different positions and companies talked to me KDB+ is a TimeSeries Database. However, I don't think TimeSeries is a feature of KDB+, whose real feature is the column oriented storage engine. That is to say with a column oriented storage engine, that KDB+ is friendly to store TimeSeries data. While in these days, column oriented storage engine does not belong to KDB+ exclusive. For traditional RDBMS, like MySQL, you can also find corresponding column storage engines in the open source communities.

The last and the most important, I want to talk about the developer friendliness. KDB+ is distributed along with a DSL, which is q. q is very developer unfriendly. When an error encountered, it just raise the error type, without any line information for you to anchor, which increase the difficulty to bug fixing and code maintenance.

Alternatives to KDB+ I can come up with:

  1. to give the system column oriented storage, a traditional K-V store works, even a column storage backed RDBMS;
  2. for the in-memory feature, a lot of open source implementation of in-memory cache, like redis, memcached, etc.

The key feature for the alternative, I think, is that the API is written in standard C/C++. You could have a lot of utilities to ease your development.

$\endgroup$
9
  • 2
    $\begingroup$ While not definitive as far as speed goes, it certainly helps that the entire executable is roughly 400kb, depending on the version, meaning it can live entirely in CPU cache. $\endgroup$
    – afekz
    Commented Jun 23, 2014 at 11:04
  • $\begingroup$ @afekz Thank you for your comments. But if not for speed, why do people bothering the cache? :p Yes, you're right this may be one of the pros for KDB. $\endgroup$ Commented Jun 23, 2014 at 12:12
  • 1
    $\begingroup$ One reason KDB is so friendly to Time Series data is that queries are implicitly stable in terms of row ordering. Many other solutions listed don't offer this guarantee. $\endgroup$
    – Chuu
    Commented Jun 2, 2015 at 19:16
  • $\begingroup$ @Chuu Thank you for your comment. By "other solutions", may I know your alternatives? :) $\endgroup$ Commented Jun 3, 2015 at 2:05
  • 1
    $\begingroup$ DolphinDB is a great alternative if the users do not have experience in array programming language. $\endgroup$
    – Wei Qiu
    Commented Mar 19, 2022 at 1:31
17
$\begingroup$

You could look into Pandas, a Python library that integrates with PyTables. It was created by someone at AQR and has some similar features as KDB.

$\endgroup$
12
$\begingroup$

KDB is useful for two reasons: - Storage of data; and easy access to the data (i.e. querying ticks..etc) - Rich query language that supports many Quant functions

however; what KDB does not do well; is the quant query language.

I have evaluated KDB, Matlab, and R. So far R is the winner.

I have not found any fast solution for storing and retrieving data; compared to using flat binary files; which are divided by month for ease of acces. My app can read 1 million of tick data in 3 seconds; and do backtesting accordingly.

for retail traders; i suggest you use flat files (binary instead of text; for quick read/write). MT4 data structure is a good example to follow.

It is cheap, free, and fast!!!

$\endgroup$
9
  • 22
    $\begingroup$ How do you compare a database system and two scientific-oriented programming languages? $\endgroup$
    – SRKX
    Commented Apr 2, 2012 at 15:56
  • $\begingroup$ can you rephrase your question? $\endgroup$
    – alpha
    Commented Apr 3, 2012 at 0:05
  • 3
    $\begingroup$ KDB is a database. Matlab and R are programming languages/environments. Q is KDB's programming language and would be somewhat comparable strictly as a language to J. $\endgroup$ Commented Apr 8, 2012 at 22:20
  • 3
    $\begingroup$ @Chuu, do you have any data to back up your claim? $\endgroup$
    – Datageek
    Commented Apr 7, 2014 at 11:07
  • 2
    $\begingroup$ @Datageek Most KDB users are intimately aware that KDB+ is a column store because administrating it requires in-depth knowledge of the on-disk structure of the database. Also, keep in mind that KDB is an in-memory database, and the insert performance numbers cited do not include persisting to disk. $\endgroup$
    – Chuu
    Commented Apr 7, 2014 at 14:10
11
$\begingroup$

We've created a roundup of the top column-oriented database systems: http://www.timestored.com/time-series-data/column-oriented-databases

This includes kdb+ and some open source alternatives.

Open: InfluxDB, Java Chronicles, OpenTSDB, KairosDB

Closed: oneTick, McObject, Teradata Database, vectorwise, sybase, vertica

We have done some initial work at benchmarking common time-series queries and found open source monetDB to be particularly fast...we will hopefully be able to publish some of those results at a later date.

$\endgroup$
9
$\begingroup$

Have a look at Kona which is a FOSS project trying to be compatible. Also Tom Szczesny has done some work on its predecessors namely A. I hope this helps.

Also if you are not looking for a perfect substitute you can have a look at other Time Series Databases like InfluxDB, Java Chronicles, OpenTSDB, KairosDB which are all Open Source. There are commercial ones as well out of which OneTick is targeted at Tick Data management.

$\endgroup$
6
$\begingroup$

At the risk of reopening an old question, I thought that I would offer my experience.

I worked for a competitor of Man AHL (who created artic). We used a columnar database called HP Vertica. Its not free unfortunately. We used it as a huge time series database for many use cases. We had one cluster of 3 fairly powerful machines that gave us redundancy if one failed, and had tables with over 100bn rows without issues. It is SQL compliant, and ACID compliant. There were tweaks that could be made to control table/column compression & distribution and replication.

It has great support for datawarehouse operations, like fast ingestion and deferrable constraints.

It did helpful things like auto-normalisation of low cardinality columns etc - ie, one could control the logical and physical schema quite precisely and easily. We could run a select distinct of a single column over 130bn+ rows in less that 10ms. We used it for time series storage (daily and tick) with one observation per row (ie, one tick/close etc per row).

We were able to build some interesting patterns:

  • We could store all incoming data against source identifiers (eg, bloomberg ticker), and then pre-materialize the symbology joins vs our internal identifiers.
  • We could store all versions of a tick and pre-materialize the filter for only the latest values.
  • We wrote a batch job that could copy entire SQL server databases directly into the data warehouse - with automatic handling of nice columns / tables etc. This made dealing with legacy / small / complex datasets very nice as now you could join all enterprise schemas over a single SQL connection. The data scientists used that a LOT.

We were able to do that over the entire dataset of 20k+ symbols * 20+ years of tick data as a series of daily batch runs. This made it very easy to manage the dataset for operators, as they could write selects and deletes using the standard SQL that we all love.

The jdbc driver was also pretty good and offered all the usual semantics and datatypes. At one point I also hooked it up to an apache Spark cluster of 256 cores and managed to achieve a parallel write over jdbc to the same destination table of over 1.2m rows per second (including the commit).

The developer experience was great as it just mainly worked as a massively powerful RMDBS with a lovely SQL experience. Vertica / HP has invested a great deal of time in providing many useful helper functions (time & date, and analytical functions) and the overall feeling was quite similar to PostgreSQL (which is a good thing).

Overall, a nice way to achieve horizontal scalability with little required of the developer or the DBA. You just need your cheque book.

Nowadays, even this approach is probably out of data now that we have things like (really) fast SSDs, cheaper and larger RAM capabilities (epyc rome supports 4TB ram on a single machine!), SPARK, and better tooling around NoSQL implementations. We also have great new initiatives like TimeScaleDB that is FOSS. Combine FOSS with the short setup times of modern hardware on public cloud and you could probably iterate to something similar for little upfront time and money.

$\endgroup$
6
$\begingroup$

The only thing which comes close to kdb in my opinion is QuestDB.

They are one of the few projects as a TSDB which have speed as a priority. They recently added out-of-order inserts which allowed them to benchmark agains some of the other TSDBs out there and the results were a quite impressive 1.4 millions writes per second (source).

I have been using it (having switched from Influx) and so far it's the best thing I have found.

$\endgroup$
4
$\begingroup$

Recent benchmarks of KDB+ vs. other big data technologies, Kdb still comes out on top 5, especially considering hardware costs for this particular data set.

[1.1 Billion Taxi Rides on kdb+/q & 4 Xeon Phi CPUs] http://tech.marksblogg.com/billion-nyc-taxi-kdb.html

$\endgroup$
3
$\begingroup$

Lots of people focus on data storage ability and compare KDB with other SQL/query-based databases. Such comparison is like considering "Is a Ferrari good for running a bus route?"

KDB+ is capable of manipulating and querying large data set. The performance is fast (in comparison to most RDBMS) due to its column based storage, but it's not her strongest suit. In fact, it could become a serious pain if the query is not well written or when the server just doesn't have enough memory. From my experience, lots of KDB applications do not even host Realtime/Historical databases.

With her simple messages publish/subscribe mechanism and flexible IPC calls, one could build complex event processing engines (and even a network of engines) to operate on these time series data easily. Its performance can easily outmatch other engines written in Java/C due to Q vector processing and loads of functions that tailored made for time series data.

$\endgroup$
2
  • $\begingroup$ Hi MK Lee, what do you mean by 'her' in 'With her simple messages'? $\endgroup$
    – Bob Jansen
    Commented Jan 5, 2015 at 12:36
  • 1
    $\begingroup$ @BobJansen Lee's been using her throughout, in place of and interchangably with KDB+ $\endgroup$
    – stucash
    Commented Dec 15, 2022 at 2:45
2
$\begingroup$

If you're looking for a columnar store alternative, have a look at Druid.io

Druid is a good fit if you are after 1. fast aggregations and searches 2. Real-time analysis 3. Huge amount of data (petabytes) 4. High availability data store with no single point of failure Source: http://druid.io/druid.html

$\endgroup$
2
$\begingroup$

One of the reasons q/kdb+ is attractive for tick data is that it can process data tick by tick as well as using the SQL-like query language. You'll read elsewhere that it is a columnar database that uses the vector processor on modern CPUs for noticeably faster throughput.

The only system I've used that can process a tick-feed like q/kdb+ is Esper. It is very difficult to work with because it's an embedded language invoked by an Esper runtime environment within a JVM. There are extra tools available at a fee.

It is possible now to use columnar datastores with Spark/Hadoop: Parquet.

I've used q/kdb+ extensively. The licence changes are really good, I can now use it as part of my toolkit at work and use it within business processes. If you persevere with it, you do appreciate it is an amazing system.

$\endgroup$
2
$\begingroup$

Axibase Time Series Database is free on a single node regardless of RAM, CPU, disk. You can store trades, Level 1 quotes, order book statistics, day/auction summaries and reference data for instruments of various types.

Time precision is microseconds.

Supports SQL with various functions for filtering by trading calendar, auction stages, indices etc.

SELECT datetime, symbol, close(), vwap()
  FROM atsd_trade
WHERE in_index('<index-name>')
  AND in_session(DAY, CLOSING)
  AND datetime BETWEEN '2021-01-01' AND '2021-01-15' EXCL
GROUP BY exchange, class, symbol, PERIOD(1 DAY)

(I work Axibase)

$\endgroup$
2
$\begingroup$

If you need the column-store for OLAP use cases (not the time series, but this could be done too), try Clickhouse, for 1.1 billion taxi benchmark, it comes 2nd after kx kdb+, and the fastest if eliminating all databases with GPU-based/Xeon-Phi setup.

You may also want to try the newer TiDB that optimized for scaling, it has TiFlash for OLAP use cases

$\endgroup$
2
$\begingroup$

We used Vertica at my last job at a large proprietary trading firm with hundreds of employees.

$\endgroup$
2
$\begingroup$

If you absolutely need a DBMS, the two obvious candidates are Clickhouse and QuestDB, which others have mentioned.

However, there are good chances that you don't need a DBMS. In which case, a plain binary flat file or one with some structure (like HDF5, Parquet) is often the best way to go.

Edit (Dec 16, 2022)

Among flat file options, I now highly recommend the use of Databento Binary Encoding.

  • It's written in Rust, with C++ and Python bindings available.
  • It's blazing fast thanks to zero copy semantics, binary format and cache line optimization. Benchmarks on a 2020 MacBook Air with the Databento Python client library:
    • Reads are practically I/O-bound at 3.5 GB/s with a single core.
    • Writes are compression-bound at 1.3 GB/s.
  • Extremely compact because it primarily uses zstd.
  • It's very easy to read into pandas in Python and reserialize it to third party storage formats (pyarrow/parquet, HDF5).
  • It's versatile:
    • The protocol supports some instrument metadata and symbology.
    • It's suitable as a message encoding or wire format. We already use it for all our internal normalized market data messages and externally for real-time market data.
    • It's suitable as a on-disk file storage format. We use it internally to store over 3 PB of normalized data, and as the default encoding for all of our customers. Compare this to something like ArcticDB, which has only been used in production at 50+ TB scale.
$\endgroup$
1
  • $\begingroup$ Disclosure: I'm one of the developers. $\endgroup$
    – databento
    Commented Dec 16, 2022 at 9:58
2
$\begingroup$

man-group/ArcticDB: High performance datastore for time series and tick data seems a good alternative for time series and tick data. It is built upon mongodb.

$\endgroup$
1
  • $\begingroup$ + for Arctic - very nice! $\endgroup$
    – chris
    Commented Feb 17, 2020 at 14:22
1
$\begingroup$

Actually, there is https://theplatform.technology. It does a bit more than kdb, but the internal language is quite close to k with some modern extensions (like pattern matching, etc)

$\endgroup$
1
  • $\begingroup$ Your work here is really impressive- keep it up! $\endgroup$
    – cjm2671
    Commented Mar 12, 2023 at 23:18
0
$\begingroup$

Nowadays many RDBMS do inmemory and columnstore. SQL Server 2017 can do that, and runs very fast

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.