Subject | Performance question (repost) |
---|---|
Author | Didier Gasser-Morlay |
Post date | 2003-06-22T10:35:03Z |
I posted this on the Atkins news server 2 days ago, but did not see it
appear, nor any answer. So here we go again and sorry if some people
have already seen this:
Hi,
using FB 1.0.3 on Linux and PHP.
I have got the following scenario
Table Project :
project_id integer (PK),
template_id, (defines the type of project & the template to apply)
more data ...
Table project_data
PROJECT_ID integer not null,
Column_id integer not null,
int_val integer,
num_val decimal (12,6),
date_val date,
char_val varchar(255)
project_id and column_id together are making the PK
I will soon have over 1 million records in this table.
each project's data is held in multiple records, according to a
template (linked using template_id) which defines what records can be
created and which what type of data (int, num, date, char). A template
defines between 20 and 80 records per type of project.
Not all the data is known when the project is created, not all
projects will need all the data defined in a template.
During the project's life, some data will be available and some will
be updated from different sources. (Delphi front end, a PHP front end,
some through a cron'ed script via ISQL).
my question: what would be the most efficient thing to do if I want to
either create a record if it does not exist OR update the record if it
exists:
A: try to insert first, see if that fails & then update the existing
record
or
B: try to update & if that fails, then attempt to create the record?
I did a small prototype to test both options but it is difficult to
emulate properly the real activity, with all users connected and reach
a definite answer.
Thanks in advance for your thoughts
Didier
appear, nor any answer. So here we go again and sorry if some people
have already seen this:
Hi,
using FB 1.0.3 on Linux and PHP.
I have got the following scenario
Table Project :
project_id integer (PK),
template_id, (defines the type of project & the template to apply)
more data ...
Table project_data
PROJECT_ID integer not null,
Column_id integer not null,
int_val integer,
num_val decimal (12,6),
date_val date,
char_val varchar(255)
project_id and column_id together are making the PK
I will soon have over 1 million records in this table.
each project's data is held in multiple records, according to a
template (linked using template_id) which defines what records can be
created and which what type of data (int, num, date, char). A template
defines between 20 and 80 records per type of project.
Not all the data is known when the project is created, not all
projects will need all the data defined in a template.
During the project's life, some data will be available and some will
be updated from different sources. (Delphi front end, a PHP front end,
some through a cron'ed script via ISQL).
my question: what would be the most efficient thing to do if I want to
either create a record if it does not exist OR update the record if it
exists:
A: try to insert first, see if that fails & then update the existing
record
or
B: try to update & if that fails, then attempt to create the record?
I did a small prototype to test both options but it is difficult to
emulate properly the real activity, with all users connected and reach
a definite answer.
Thanks in advance for your thoughts
Didier