Author Topic: Best solution for large local database  (Read 2025 times)

0 Members and 1 Guest are viewing this topic.

Offline vasouv

  • Thread Starter
  • Posts: 88
  • Location: Greece
Best solution for large local database
« on: Wed, 28 August 2013, 17:24:11 »
Hello fellow coders, I'd like some advice on a project I'm building. I have a 35MB SQL file that inserts data to the database, my machine needed ~2 hours to insert all the data in MySQL. The largest table has around half a million entries.

Now, since I'm building the app on my machine, it's fairly easy since I can start the server, test the app etc. If I want to test the app on a linux system or give it to a friend to test it etc, I must set the MySQL server again and re-run the SQL file. It's a bit of a p.i.t.a. 'cause each system will need to be configured separately. I believe this goes for each of the big RDBMSs.

My first choice was SQLite (single file DB), though I don't think it's supposed to be used in large databases such as mine, with so many thousands of entries.

The obvious (and possibly the best) solution to this, would be to rent a MySQL server and be on my merry way. I don't want to do that yet though, that might happen if I decide to make my app a web one, and go commercial.

So, what do you think is the best approach to this?

Offline rowdy

  • HHKB Hapster
  • * Erudite Elder
  • Posts: 21175
  • Location: melbourne.vic.au
  • Missed another sale.
Re: Best solution for large local database
« Reply #1 on: Thu, 29 August 2013, 03:59:46 »
You could try something like Firebird.

It's feature set is pretty limited, but unless it has changed radically in the last few years you could setup a database which would store all the data in a single file, then just backup, or even rename (to make sure nothing is accessing it) and copy the database file itself.
"Because keyboards are accessories to PC makers, they focus on minimizing the manufacturing costs. But that’s incorrect. It’s in HHKB’s slogan, but when America’s cowboys were in the middle of a trip and their horse died, they would leave the horse there. But even if they were in the middle of a desert, they would take their saddle with them. The horse was a consumable good, but the saddle was an interface that their bodies had gotten used to. In the same vein, PCs are consumable goods, while keyboards are important interfaces." - Eiiti Wada

NEC APC-H4100E | Ducky DK9008 Shine MX blue LED red | Ducky DK9008 Shine MX blue LED green | Link 900243-08 | CM QFR MX black | KeyCool 87 white MX reds | HHKB 2 Pro | Model M 02-Mar-1993 | Model M 29-Nov-1995 | CM Trigger (broken) | CM QFS MX green | Ducky DK9087 Shine 3 TKL Yellow Edition MX black | Lexmark SSK 21-Apr-1994 | IBM SSK 13-Oct-1987 | CODE TKL MX clear | Model M 122 01-Jun-1988

Ị̸͚̯̲́ͤ̃͑̇̑ͯ̊̂͟ͅs̞͚̩͉̝̪̲͗͊ͪ̽̚̚ ̭̦͖͕̑́͌ͬͩ͟t̷̻͔̙̑͟h̹̠̼͋ͤ͋i̤̜̣̦̱̫͈͔̞ͭ͑ͥ̌̔s̬͔͎̍̈ͥͫ̐̾ͣ̔̇͘ͅ ̩̘̼͆̐̕e̞̰͓̲̺̎͐̏ͬ̓̅̾͠͝ͅv̶̰͕̱̞̥̍ͣ̄̕e͕͙͖̬̜͓͎̤̊ͭ͐͝ṇ̰͎̱̤̟̭ͫ͌̌͢͠ͅ ̳̥̦ͮ̐ͤ̎̊ͣ͡͡n̤̜̙̺̪̒͜e̶̻̦̿ͮ̂̀c̝̘̝͖̠̖͐ͨͪ̈̐͌ͩ̀e̷̥͇̋ͦs̢̡̤ͤͤͯ͜s͈̠̉̑͘a̱͕̗͖̳̥̺ͬͦͧ͆̌̑͡r̶̟̖̈͘ỷ̮̦̩͙͔ͫ̾ͬ̔ͬͮ̌?̵̘͇͔͙ͥͪ͞ͅ

Offline phoenix1234

  • Posts: 584
  • Location: Saigon - Vietnam
Re: Best solution for large local database
« Reply #2 on: Thu, 29 August 2013, 05:25:42 »
Hello fellow coders, I'd like some advice on a project I'm building. I have a 35MB SQL file that inserts data to the database, my machine needed ~2 hours to insert all the data in MySQL. The largest table has around half a million entries.

Now, since I'm building the app on my machine, it's fairly easy since I can start the server, test the app etc. If I want to test the app on a linux system or give it to a friend to test it etc, I must set the MySQL server again and re-run the SQL file. It's a bit of a p.i.t.a. 'cause each system will need to be configured separately. I believe this goes for each of the big RDBMSs.

My first choice was SQLite (single file DB), though I don't think it's supposed to be used in large databases such as mine, with so many thousands of entries.

The obvious (and possibly the best) solution to this, would be to rent a MySQL server and be on my merry way. I don't want to do that yet though, that might happen if I decide to make my app a web one, and go commercial.

So, what do you think is the best approach to this?

I'm quite sure that your first choice sqlite is the best choice.
It is because sqlite can handle up to Tetra-bytes system.
So I don't think a millions of records will be any issue with sqlite.
 :thumb:
I like linear switches

Offline vasouv

  • Thread Starter
  • Posts: 88
  • Location: Greece
Re: Best solution for large local database
« Reply #3 on: Thu, 29 August 2013, 13:26:55 »
SQLite eh? Yeah I guess it's the best choice since I need to transfer the DB along with the app.

Firebird I'd never heard of but I'll take a look at, I see it has a Java driver and a .net one.

I even considered the embeddable DerbyDB but eeeh, will make the executable too big I guess.

Oh well, here's to another 2hrs of populating a SQLite db to start with...

Thanks guys :)

Offline rowdy

  • HHKB Hapster
  • * Erudite Elder
  • Posts: 21175
  • Location: melbourne.vic.au
  • Missed another sale.
Re: Best solution for large local database
« Reply #4 on: Thu, 29 August 2013, 17:16:46 »
Have you tried disabling indexes before doing the import, then enabling them afterwards?

Often faster to do that.
"Because keyboards are accessories to PC makers, they focus on minimizing the manufacturing costs. But that’s incorrect. It’s in HHKB’s slogan, but when America’s cowboys were in the middle of a trip and their horse died, they would leave the horse there. But even if they were in the middle of a desert, they would take their saddle with them. The horse was a consumable good, but the saddle was an interface that their bodies had gotten used to. In the same vein, PCs are consumable goods, while keyboards are important interfaces." - Eiiti Wada

NEC APC-H4100E | Ducky DK9008 Shine MX blue LED red | Ducky DK9008 Shine MX blue LED green | Link 900243-08 | CM QFR MX black | KeyCool 87 white MX reds | HHKB 2 Pro | Model M 02-Mar-1993 | Model M 29-Nov-1995 | CM Trigger (broken) | CM QFS MX green | Ducky DK9087 Shine 3 TKL Yellow Edition MX black | Lexmark SSK 21-Apr-1994 | IBM SSK 13-Oct-1987 | CODE TKL MX clear | Model M 122 01-Jun-1988

Ị̸͚̯̲́ͤ̃͑̇̑ͯ̊̂͟ͅs̞͚̩͉̝̪̲͗͊ͪ̽̚̚ ̭̦͖͕̑́͌ͬͩ͟t̷̻͔̙̑͟h̹̠̼͋ͤ͋i̤̜̣̦̱̫͈͔̞ͭ͑ͥ̌̔s̬͔͎̍̈ͥͫ̐̾ͣ̔̇͘ͅ ̩̘̼͆̐̕e̞̰͓̲̺̎͐̏ͬ̓̅̾͠͝ͅv̶̰͕̱̞̥̍ͣ̄̕e͕͙͖̬̜͓͎̤̊ͭ͐͝ṇ̰͎̱̤̟̭ͫ͌̌͢͠ͅ ̳̥̦ͮ̐ͤ̎̊ͣ͡͡n̤̜̙̺̪̒͜e̶̻̦̿ͮ̂̀c̝̘̝͖̠̖͐ͨͪ̈̐͌ͩ̀e̷̥͇̋ͦs̢̡̤ͤͤͯ͜s͈̠̉̑͘a̱͕̗͖̳̥̺ͬͦͧ͆̌̑͡r̶̟̖̈͘ỷ̮̦̩͙͔ͫ̾ͬ̔ͬͮ̌?̵̘͇͔͙ͥͪ͞ͅ

Offline vasouv

  • Thread Starter
  • Posts: 88
  • Location: Greece
Re: Best solution for large local database
« Reply #5 on: Fri, 30 August 2013, 02:02:37 »
No I hadn't tried that to be honest. The SQL file I have, doesn't create indexes (or primary keys for the matter of fact, I add them later).

For starters, I'll try SQLite through command-line, I'll leave the Firefox extension out of this since it derped up yesterday...

If that doesn't work out, I'll write a program that reads from MySQL and writes to MongoDB, there are a couple hosts that provide 512MB databases for free, eh, better than nothing. Want to check out MongoDB anyway.

Offline phoenix1234

  • Posts: 584
  • Location: Saigon - Vietnam
Re: Best solution for large local database
« Reply #6 on: Mon, 02 September 2013, 04:48:25 »
No I hadn't tried that to be honest. The SQL file I have, doesn't create indexes (or primary keys for the matter of fact, I add them later).

For starters, I'll try SQLite through command-line, I'll leave the Firefox extension out of this since it derped up yesterday...

If that doesn't work out, I'll write a program that reads from MySQL and writes to MongoDB, there are a couple hosts that provide 512MB databases for free, eh, better than nothing. Want to check out MongoDB anyway.

Derby is ok and reliable but please note that Derby is Java-based so it is up to you whether to have jvm or not.

For Sqlite manager, you can take a look at sqliteman (http://sqliteman.com/) instead of Sqlite Manager Firefox Plugin.
I like linear switches

Offline agodinhost

  • Posts: 767
  • Location: Brazil, RJ
  • Soylent green is people ...
    • Dr Ian O Xaman
Re: Best solution for large local database
« Reply #7 on: Mon, 02 September 2013, 07:48:04 »
What's the problem with the MySQL man?
A 500k insert will take time whatever database you choose.
sqLite is lighter and quicker but only because it doesn't have a few features

SQLite:

    easier to setup
    great for temporary (testing databases)
    great for rapid development
    great for embedding in an application
    doesn't have user management
    doesn't have many performance features
    doesn't scale well.

MySQL:

    far more difficult/complex to set up
    better options for performance tuning
    can scale well if tuned properly
    can manage users, permissions, etc.

take a look at here
Building one square I2C keyboard with those 1200 switches (thanks JDCarpe)
GH60 |GH60-Alps |GH60-BT |GHPad/GHPad Alps |GH60-Case |Alps TKL |EL Wire |OS Controller, Round 2 |My Custom Keyboard |WTT/WTB

Offline JPG

  • Posts: 1124
  • Location: Canada (Beloeil, near Montreal)
  • Model F is my new passion!
Re: Best solution for large local database
« Reply #8 on: Mon, 02 September 2013, 08:00:27 »
I don't know them all, but I work a lot with MSSQL server and I got some experience with oracle and I know that both offer a free "express" version. There are some limitations, but for a personal database you should be way ok.

I use MSSQL server at job and I like it a lot. There's a lot of powerfull tools and you can end up using the guy interface if you want (easier if you are new) or do it all by commands.

As for your objective, well you could simply load all the data and make a backup of the database. The you would only need to restore the database, which will take as long as you need to write it to the disk. You could also make your database available through internet, but it could be annoying if you don't have a static IP.

Also, I never used MySQL, but I am pretty sure you can do all of this with it since it's used a lot, even in big production environments.
IBM F122, IBM XT F X2, IBM AT F (all Soarer converted), Filco Camo TKL Browns

Offline daerid

  • Posts: 4276
  • Location: Denver, CO
    • Rossipedia
Re: Best solution for large local database
« Reply #9 on: Mon, 02 September 2013, 09:56:53 »
I've been using MySQL on and off again for over 10 years, and I've hated it every time.

Offline vasouv

  • Thread Starter
  • Posts: 88
  • Location: Greece
Re: Best solution for large local database
« Reply #10 on: Mon, 02 September 2013, 12:36:17 »
There were some "advances" since the last time I posted here. I managed to find an actual SQLite database file of the data I wanted. So I'll just work off that when I start.

I don't have a problem with MySQL, I think it's fine, but for my (starting) purpose I believe it's unnecessary trouble. I'd have to install it on all machines blah blah blah, keep it updated...

If I decide to take my project out in the open sure, I'll have to rent a MySQL server or similar and work off that but for prototyping purposes (as you pointed out) SQLite is easier to handle.

Besides, I'm about to install WAMP for web dev so I'll have MySQL for all my projects anyway. Static IPs and stuff are not an option right now :)

phoenix I'm downloading that program, I don't really like the FF extension...

Offline rowdy

  • HHKB Hapster
  • * Erudite Elder
  • Posts: 21175
  • Location: melbourne.vic.au
  • Missed another sale.
Re: Best solution for large local database
« Reply #11 on: Tue, 03 September 2013, 05:13:48 »
I used to use MySQL - I liked its simplicity, feature-set, comprehensive SQL, operating system transparency (each database in its own directory, each table in its own files).

But then Oracle bought it and went all silly with licencing.

So now I use PostgreSQL.
"Because keyboards are accessories to PC makers, they focus on minimizing the manufacturing costs. But that’s incorrect. It’s in HHKB’s slogan, but when America’s cowboys were in the middle of a trip and their horse died, they would leave the horse there. But even if they were in the middle of a desert, they would take their saddle with them. The horse was a consumable good, but the saddle was an interface that their bodies had gotten used to. In the same vein, PCs are consumable goods, while keyboards are important interfaces." - Eiiti Wada

NEC APC-H4100E | Ducky DK9008 Shine MX blue LED red | Ducky DK9008 Shine MX blue LED green | Link 900243-08 | CM QFR MX black | KeyCool 87 white MX reds | HHKB 2 Pro | Model M 02-Mar-1993 | Model M 29-Nov-1995 | CM Trigger (broken) | CM QFS MX green | Ducky DK9087 Shine 3 TKL Yellow Edition MX black | Lexmark SSK 21-Apr-1994 | IBM SSK 13-Oct-1987 | CODE TKL MX clear | Model M 122 01-Jun-1988

Ị̸͚̯̲́ͤ̃͑̇̑ͯ̊̂͟ͅs̞͚̩͉̝̪̲͗͊ͪ̽̚̚ ̭̦͖͕̑́͌ͬͩ͟t̷̻͔̙̑͟h̹̠̼͋ͤ͋i̤̜̣̦̱̫͈͔̞ͭ͑ͥ̌̔s̬͔͎̍̈ͥͫ̐̾ͣ̔̇͘ͅ ̩̘̼͆̐̕e̞̰͓̲̺̎͐̏ͬ̓̅̾͠͝ͅv̶̰͕̱̞̥̍ͣ̄̕e͕͙͖̬̜͓͎̤̊ͭ͐͝ṇ̰͎̱̤̟̭ͫ͌̌͢͠ͅ ̳̥̦ͮ̐ͤ̎̊ͣ͡͡n̤̜̙̺̪̒͜e̶̻̦̿ͮ̂̀c̝̘̝͖̠̖͐ͨͪ̈̐͌ͩ̀e̷̥͇̋ͦs̢̡̤ͤͤͯ͜s͈̠̉̑͘a̱͕̗͖̳̥̺ͬͦͧ͆̌̑͡r̶̟̖̈͘ỷ̮̦̩͙͔ͫ̾ͬ̔ͬͮ̌?̵̘͇͔͙ͥͪ͞ͅ

Offline nuclearsandwich

  • Posts: 752
  • Location: Santa Clara Valley, CA
Re: Best solution for large local database
« Reply #12 on: Tue, 03 September 2013, 10:15:43 »
sqlite's primary limitation isn't database size but concurrency. As long as only one process/thread needs to access the database at any given time. It's great!