Can SQLite handle 90 million records?
Are you inserting all of the 800 elements at once? If you are, doing the inserts within a transaction will speed up the process dramatically.
See http://www.sqlite.org/faq.html#q19
SQLite can handle very large databases. See http://www.sqlite.org/limits.html
is there a limit to the size of a SQLite database?
This is fairly easy to deduce from the implementation limits page:
An SQLite database file is organized as pages. The size of each page is a power of 2 between 512 and SQLITE_MAX_PAGE_SIZE. The default value for SQLITE_MAX_PAGE_SIZE is 32768.
...
The SQLITE_MAX_PAGE_COUNT parameter, which is normally set to 1073741823, is the maximum number of pages allowed in a single database file. An attempt to insert new data that would cause the database file to grow larger than this will return SQLITE_FULL.
So we have 32768 * 1073741823, which is 35,184,372,056,064 (35 trillion bytes)!
You can modify SQLITE_MAX_PAGE_COUNT
or SQLITE_MAX_PAGE_SIZE
in the source, but this of course will require a custom build of SQLite for your application. As far as I'm aware, there's no way to set a limit programmatically other than at compile time (but I'd be happy to be proven wrong).
Database with a table containing 700 million records
Go for SQL Server for sure. 700 million records in SQLite is too much.
With SQLite you have following limitation
- Single process write.
- No mirroring
- No replication
Check out this thread: What are the performance characteristics of sqlite with very large database files?
SQLite Optimization for Millions of Entries?
If $db
is undefined, opening the database is failing, and you should inspect $!
and $BerkeleyDB::Error
to see why.
Have you created the database already? If not, you need -Flags => DB_CREATE
.
Working example:
use strict;
use warnings;
use BerkeleyDB;
my $dbFolder = '/home/ysth/bdbtmp/';
my $db = BerkeleyDB::Hash->new (
-Filename => "$dbFolder/fred.db",
-Flags => DB_CREATE,
) or die "couldn't create: $!, $BerkeleyDB::Error.\n";
my $status = $db->db_put("apple", "red");
I couldn't get BerkeleyDB::Env to do anything useful, though; whatever I tried, the constructor returned undef.
SQLite insert speed slows as number of records increases due to an index
If your requirement is to find a particular z_id
and the x_ids
and y_ids
linked to it (as distinct from quickly selecting a range of z_ids
) you could look into a non-indexed hash-table nested-relational db that would allow you to instantly find your way to a particular z_id
in order to get its y_ids
and x_ids
-- without the indexing overhead and the concomitant degraded performance during inserts as the index grows. In order to avoid clumping (aka bucket collisions), choose a key hashing algorithm that puts greatest weight on the digits of z_id
with greatest variation (right-weighted).
P.S. A database that uses a b-tree may at first appear faster than a db that uses linear hashing, say, but the insert performance will remain level with the linear hash as performance on the b-tree begins to degrade.
P.P.S. To answer @kawing-chiu's question: the core feature relevant here is that such a database relies on so-called "sparse" tables in which the physical location of a record is determined by a hashing algorithm which takes the record key as input. This approach permits a seek directly to the record's location in the table without the intermediary of an index. As there is no need to traverse indexes or to re-balance indexes, insert-times remain constant as the table becomes more densely populated. With a b-tree, by contrast, insert times degrade as the index tree grows. OLTP applications with large numbers of concurrent inserts can benefit from such a sparse-table approach. The records are scattered throughout the table. The downside of records being scattered across the "tundra" of the sparse table is that gathering large sets of records which have a value in common, such as a postal code, can be slower. The hashed sparse-table approach is optimized to insert and retrieve individual records, and to retrieve networks of related records, not large sets of records that have some field value in common.
A nested relational database is one that permits tuples within a column of a row.
Can I bind a database with million records to a listbox?
You should virtualize UI and data loading. You can't just bind 1,000,000 item collection to the list without any code. Read this tutorial about displaying large data sets.
Save 5000 object in my sql lite data base
Try to use transactions to do multiple inserts.
You can only do very few commits per second but lots of inserts per transaction.
http://www.sqlite.org/faq.html#q19
Related Topics
Connect SQL Server in Ruby on Rails
How to Connect to SQL Server 2005 Database Through Ruby
Why am I Able to Call the Class Method as If It Were an Instance Method Here
Standard SQL Boolean Operator Is VS. Equals (=) Operator
Replacing Null and Empty String Within Select Statement
SQL Server: Replace Invalid Xml Characters from a Varchar(Max) Field
SQL Pulling a Row for Next or Previous Row of a Current Row
Create a Delimitted String from a Query in Db2
What Is "Connect Timeout" in SQL Server Connection String
How to Combine Results of Two Queries into a Single Dataset
Inner Join VS Multiple Table Names in "From"
Writing a Subquery Using Zend Db
Rails 3 Activerecord Query Using Both SQL in and SQL or Operators
How to Properly Add Brackets to SQL Queries with 'Or' and 'And' Clauses by Using Arel
Sqlite Inner Join - Update Using Values from Another Table