Subject | Re: [firebird-support] Storing BLOB's |
---|---|
Author | Helen Borrie |
Post date | 2007-03-19T00:52:59Z |
At 10:59 AM 19/03/2007, you wrote:
becomes "worse" where you pull over huge chunks of unnecessary
data. With Blobs, the API actually gives you the opportunity to
leave the data associated with the blob_id that is stored in the
field on the server until you actually want it. You can (some would
say *should*) design your user applications that way, anyway.
record is a Blob_id, which is a pointer to the first page of the
blob's data "somewhere on the disk". If there is no blob, there is
no blob_id, just null there.
The engine maintains a kind of "micro-database" for each blob, where
a blob_id is sort of like a primary key to chunks of disk ("pages")
that have the same blob_id. The blob_id lives as long as a version
of the blob lives; if you change data in a blob, the old version of
the blob data is cleared out and replaced with the new version and
there will be a new blob_id once the record is committed.
In reality, sometimes the blob's data *will* be stored on the same
page as the record's data. That's a matter of logistics rather than
of logic or dependency. The engine likes to use space if it is
available and, if the blob's data is of a suitable size to fit in the
space available on the data page, the engine just takes the easy road.
It's easier to understand "good" or "bad" in *storage* terms if you
realise that Firebird doesn't store physical tables at all, as many
other DBMS's do. Relational databases are very abstract
things. "Good" and "bad" (and "beige") in RDBMS terms has to do with
how efficiently one can store and retrieve stuff. When you are
working out operations on data, think always in terms of "sets", not
tables, and the most efficient ways to construct and maintain the
working sets that are needed by your applications.
./heLen
>Hi List !No.
>
>Is it true that it is a bad idea to store BLOB's together with other
>fields in 1 table (performance) ?
>Is it better to store those fields in a seperate table ?No. It might be *convenient* to do so for some architectural requirements.
>In case it is bad : is it only bad if that field is part of the SELECTIt's always "bad" to pull over data that you don't need. "Bad"
>statement ? Or is it also bad even if the field is not included in the
>SELECT ?
becomes "worse" where you pull over huge chunks of unnecessary
data. With Blobs, the API actually gives you the opportunity to
leave the data associated with the blob_id that is stored in the
field on the server until you actually want it. You can (some would
say *should*) design your user applications that way, anyway.
>And last : What if there is no value given for the BLOB for aNo. In principle, Blobs are not stored with the record. On the
>particular record, is the database assigning space for it anyway ?
record is a Blob_id, which is a pointer to the first page of the
blob's data "somewhere on the disk". If there is no blob, there is
no blob_id, just null there.
The engine maintains a kind of "micro-database" for each blob, where
a blob_id is sort of like a primary key to chunks of disk ("pages")
that have the same blob_id. The blob_id lives as long as a version
of the blob lives; if you change data in a blob, the old version of
the blob data is cleared out and replaced with the new version and
there will be a new blob_id once the record is committed.
In reality, sometimes the blob's data *will* be stored on the same
page as the record's data. That's a matter of logistics rather than
of logic or dependency. The engine likes to use space if it is
available and, if the blob's data is of a suitable size to fit in the
space available on the data page, the engine just takes the easy road.
It's easier to understand "good" or "bad" in *storage* terms if you
realise that Firebird doesn't store physical tables at all, as many
other DBMS's do. Relational databases are very abstract
things. "Good" and "bad" (and "beige") in RDBMS terms has to do with
how efficiently one can store and retrieve stuff. When you are
working out operations on data, think always in terms of "sets", not
tables, and the most efficient ways to construct and maintain the
working sets that are needed by your applications.
./heLen