-- 1000,000 rows
CREATE TABLE cell (
cell_id INTEGER PRIMARY KEY,
met_cell_id INTEGER,
8 other INTEGER or REAL columns
)
-- 38 rows
CREATE TABLE lc (
lc_id INTEGER PRIMARY KEY,
56 other INTEGER or REAL columns
)
-- 10 rows
CREATE TABLE dist (
dist_id INTEGER PRIMARY KEY,
37 other INTEGER or REAL columns
)
-- 2,920,000 rows
CREATE TABLE met (
met_id INTEGER PRIMARY KEY,
met_cell_id INTEGER,
9 other INTEGER or REAL columns
)
CREATE TABLE cell_lc (cell_id INTEGER, lc_id INTEGER)
CREATE TABLE cell_dist (cell_id INTEGER, dist_id INTEGER)
CREATE INDEX idx_met_cell_id ON met (met_cell_id)
CREATE INDEX idx_cell_lc ON cell_lc (cell_id)
CREATE INDEX idx_cell_dist ON cell_dist (cell_id)
####
[1] First retrieve all data from cell table
SELECT * FROM cell WHERE cell_id = :cell_id
[2] Now retrieve the related lc, dist and met
SELECT lc.*
FROM lc l JOIN cell_lc c on l.lc_id = c.lc_id
WHERE c.cell_id = :cell_id
[3] Retrieve the related dist
SELECT d.*
FROM dist d JOIN cell_lc c on d.dist_id = c.dist_id
WHERE c.cell_id = :cell_id
[4] Retrieve the related met
SELECT * FROM met WHERE met_cell_id =
####
[08:38 AM] ~/Data/carbonmodel$perl carbonmodel.pl
timethis 1: 0 wallclock secs ( 0.03 usr + 0.00 sys = 0.03 CPU) @ 33.33/s (n=1)
timethis 10: 0 wallclock secs ( 0.31 usr + 0.02 sys = 0.33 CPU) @ 30.30/s (n=10)
timethis 100: 3 wallclock secs ( 2.85 usr + 0.20 sys = 3.05 CPU) @ 32.79/s (n=100)
timethis 1000: 33 wallclock secs (31.08 usr + 1.22 sys = 32.30 CPU) @ 30.96/s (n=1000)
####
timethis 1000: 783 wallclock secs (732.26 usr + 18.22 sys = 750.48 CPU) @ 1.33/s (n=1000)
####
CREATE TABLE cell_blobs (cell_id INTEGER PRIMARY KEY, cell_data BLOB);