Created
September 10, 2012 01:34
-
-
Save kellabyte/3688321 to your computer and use it in GitHub Desktop.
This file contains 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
// TRY HARD SHIT. | |
// I did and I'm learning a lot. | |
// | |
// 2 days ago I had no idea what I was doing but I decided I was going to create | |
// a database. I figured this would be a great way to learn even more about the | |
// databases I use today. I will write better software because I will know how they are | |
// designed and the optimizations and limitations they have to work with. | |
// | |
// After two days I have: | |
// - Modelled column based data model (like Cassandra) on top of a key/value store (SQLite4 does I think). | |
// - Created an inverted index stored in the key/value store for fast seeking at query time. | |
// - Parse an SQL-like query syntax into an AST (abstract syntax tree). | |
// - Process the AST to generate a query execution plan to compose a database operation. | |
// - Execute the operation and return results. | |
// | |
// I had no idea how to model a column based data model or how to use an AST. | |
// I didn't even know I needed them. | |
// I didn't think it would work. I got stuck. I asked for help. I kept trying. | |
// | |
// After 2 days this now works: | |
using System; | |
using Dazzle.Database; | |
using Dazzle.Database.Query; | |
namespace Dazzle.Benchmark.Embedded | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
// The database is pre-loaded with 1 million rows each with 50 columns of gibberish data. | |
// This means 50+ million keys have been inserted into the key/value storage backend. | |
var db = new DazzleDatabase(path); | |
db.Open(); | |
var result = db.ExecuteQuery("select * from users where userid = 'kelly900000'"); | |
} | |
} | |
} | |
/* | |
OUTPUT | |
------------------------------------- | |
Rows: 1,000,000.00 Columns per row: 50 Total keys in DB: 50,000,000.00 DB Size: 2.36GB | |
Query: select * from users where userid = 'kelly900000' | |
Returned Rows: 1 Columns per row: 50 | |
Query executed in 00:00:00.0035229 | |
I can't believe this worked without any tuning in 3.5ms! | |
You can find Dazzle on GitHub here | |
https://github.com/kellabyte/Dazzle | |
*/ |
Niiice, waiting to read more about your adventure.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That is amazing! I would surely like to read about it!