Last active
February 20, 2020 15:59
-
-
Save Try-Try-Again/299c20837e928e024992a6e0dce6d034 to your computer and use it in GitHub Desktop.
Query speeds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| PostgreSQL: | |
| ryan=# select * from photos where experienceid = 1000 LIMIT 1; | |
| photoid | photourl | alt | username | experienceid | |
| ---------+-------------------------------------------------+------------+----------+-------------- | |
| 11001 | https://rybnb.s3-us-west-1.amazonaws.com/40.jpg | Automotive | Alvena | 1000 | |
| (1 row) | |
| Time: 15.333 ms | |
| ryan=# select * from photos where experienceid = 10000 AND photoid > 9000000 LIMIT 1; | |
| photoid | photourl | alt | username | experienceid | |
| ---------+-------------------------------------------------+---------+----------+-------------- | |
| 9000899 | https://rybnb.s3-us-west-1.amazonaws.com/58.jpg | Arizona | Ola | 10000 | |
| (1 row) | |
| Time: 15.201 ms | |
| COMMENTS: | |
| PostgreSQL was consistent in it's speeds. And repeated lookups to the same value were completed in under a millisecond. | |
| Cassandra: | |
| cqlsh:airbnb> select * from photos where photoid = 2; | |
| photoid | alt | experienceid | photourl | username | |
| ---------+--------+--------------+--------------------------------------------------+------------ | |
| 2 | mobile | 2 | https://rybnb.s3-us-west-1.amazonaws.com/130.jpg | Marjolaine | |
| (1 rows) | |
| Tracing session: e8b428d0-53f7-11ea-a2ad-9d8ef2550b0d | |
| activity | timestamp | source | source_elapsed | client | |
| -------------------------------------------------------------------------------+----------------------------+-----------+----------------+----------- | |
| Execute CQL3 query | 2020-02-20 07:44:41.437000 | 127.0.0.1 | 0 | 127.0.0.1 | |
| Parsing select * from photos where photoid = 2; [Native-Transport-Requests-1] | 2020-02-20 07:44:41.437000 | 127.0.0.1 | 148 | 127.0.0.1 | |
| Preparing statement [Native-Transport-Requests-1] | 2020-02-20 07:44:41.437000 | 127.0.0.1 | 285 | 127.0.0.1 | |
| Executing single-partition query on photos [ReadStage-3] | 2020-02-20 07:44:41.437001 | 127.0.0.1 | 602 | 127.0.0.1 | |
| Acquiring sstable references [ReadStage-3] | 2020-02-20 07:44:41.438000 | 127.0.0.1 | 665 | 127.0.0.1 | |
| Merging memtable contents [ReadStage-3] | 2020-02-20 07:44:41.438000 | 127.0.0.1 | 705 | 127.0.0.1 | |
| Bloom filter allows skipping sstable 21 [ReadStage-3] | 2020-02-20 07:44:41.438000 | 127.0.0.1 | 786 | 127.0.0.1 | |
| Bloom filter allows skipping sstable 22 [ReadStage-3] | 2020-02-20 07:44:41.438000 | 127.0.0.1 | 829 | 127.0.0.1 | |
| Bloom filter allows skipping sstable 11 [ReadStage-3] | 2020-02-20 07:44:41.438000 | 127.0.0.1 | 864 | 127.0.0.1 | |
| Partition index with 0 entries found for sstable 6 [ReadStage-3] | 2020-02-20 07:44:41.452000 | 127.0.0.1 | 15561 | 127.0.0.1 | |
| Read 1 live rows and 0 tombstone cells [ReadStage-3] | 2020-02-20 07:44:41.453000 | 127.0.0.1 | 16248 | 127.0.0.1 | |
| Request complete | 2020-02-20 07:44:41.453436 | 127.0.0.1 | 16436 | 127.0.0.1 | |
| cqlsh:airbnb> select * from photos where photoid = 9999999; | |
| photoid | alt | experienceid | photourl | username | |
| ---------+---------+--------------+--------------------------------------------------+---------- | |
| 9999999 | invoice | 9000 | https://rybnb.s3-us-west-1.amazonaws.com/183.jpg | Laisha | |
| (1 rows) | |
| Tracing session: f2009cf0-53f9-11ea-a2ad-9d8ef2550b0d | |
| activity | timestamp | source | source_elapsed | client | |
| -------------------------------------------------------------------------------------+----------------------------+-----------+----------------+----------- | |
| Execute CQL3 query | 2020-02-20 07:59:16.031000 | 127.0.0.1 | 0 | 127.0.0.1 | |
| Parsing select * from photos where photoid = 9999999; [Native-Transport-Requests-1] | 2020-02-20 07:59:16.032000 | 127.0.0.1 | 149 | 127.0.0.1 | |
| Preparing statement [Native-Transport-Requests-1] | 2020-02-20 07:59:16.032000 | 127.0.0.1 | 303 | 127.0.0.1 | |
| Executing single-partition query on photos [ReadStage-3] | 2020-02-20 07:59:16.032000 | 127.0.0.1 | 663 | 127.0.0.1 | |
| Acquiring sstable references [ReadStage-3] | 2020-02-20 07:59:16.032000 | 127.0.0.1 | 715 | 127.0.0.1 | |
| Merging memtable contents [ReadStage-3] | 2020-02-20 07:59:16.032000 | 127.0.0.1 | 747 | 127.0.0.1 | |
| Read 1 live rows and 0 tombstone cells [ReadStage-3] | 2020-02-20 07:59:16.032000 | 127.0.0.1 | 1007 | 127.0.0.1 | |
| Request complete | 2020-02-20 07:59:16.032171 | 127.0.0.1 | 1171 | 127.0.0.1 | |
| COMMENTS: | |
| Results were strange for cassandra. Numbers with a lower id took much longer. | |
| Records with an id approaching 10 millon were instantanious. I belive Cassandra loaded my records 'backwards'. | |
| CONCLUSION: | |
| I think Cassandra's real advantages only become apparent after scaling is nessesary. | |
| If this project is going to run on a small AWS VM, I believe PostgreSQL is the optimal choice. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment