DEV Community

Cover image for Creating a database from scratch with Node.js - Day 11
Luis Felipe Ciochetta
Luis Felipe Ciochetta

Posted on

Creating a database from scratch with Node.js - Day 11

Hello Folks!

another quick update

Changes

Changed create to create table

I've changed the create statement so it looks more like SQL, so now you have to be specific about creating a table.

I did this because I will start the indexing algorithm tomorrow and therefore, I will need the create statement to also recognize "create index".

Created a bulk insert function

I have also created a new feature, the bulk insert

it's kinda bad when working with LQL, because you actually have to type the JSON in the command line:

Alt Text

HOWEVER, when you want to insert an array it's waaaaaaaaaaay faster than inserting one document at a time, here is a test of my inserting 1k documents:

Alt Text

during my tests I had a bad time trying to insert 10k documents one at a time, it took almost a minute

and testing the bulk insert, I could insert 1M documents in 2s

I do not know how useful a bulk insert will be on a day-to-day basis, but I have created it so I can test my indexing algorithm once it's done, so I can quickly create huge databases and test how indexing will affect them

Conclusion

bulk insert is nice and fast

very excited to start indexing tomorrow

Links:

Repository for the database/driver/REPL:

GitHub logo ciochetta / learndb

Database project I've created for learning purposes

Repository for the LQL parser:

GitHub logo ciochetta / lql-parser

parser for my database project

Repository for the test I've made for this post:

GitHub logo ciochetta / testing-luisdb

Repository to test my database

Top comments (2)

Collapse
 
someone1 profile image
nagesh bs

Nice, the sql parser is interesting, ill steal this for my project 😀
I was building something similar
Its a toy transactional database
github.com/last-saiyan/acid-db

Collapse
 
ciochetta profile image
Luis Felipe Ciochetta

hey man, this project seems awesome

would you like to chat about databases?