On Mon, 2006-07-03 at 12:16 -0400, Alexandre Leclerc wrote:
> 2006/7/3, Zlatko Matić <[EMAIL PROTECTED]>:
> > Hi!
> > I downloaded the most recent snapshot (Lazarus-0.9.17-20060703-win32.exe)
> > this morning and now it finally works! I'm so excited about it, it's great!
> > Finally I can experiment with Lazarus as front-end for my PostgreSQL
> > databases. I'm so happy about it!
> >
> > Thank you very much.
> 
> I think I'll be very happy about it also.
> 
> Is there any help about memory usage when using varchar without
> limmits? (Because I'm using many of them.)

There's no documentation about it, but it's fairly simple. For every
record in memory, one unlimited varchar uses dsMaxStringSize (=8192)
bytes.

Consider a table with only two unlimited varchar's fields and with two
actual records. The records are:
'hello','world' (5+5=10 bytes)
'bye,'world'    (3+5=8 bytes)

If you open the table, the postgresql-client will allocate some memory
to store the data. That'll be 10+8=18 bytes plus something dependent on
it's own string-data-format.
At the same time TBufDataset will allocate memory for FPacketRecords
(default=10) records. Thus: 10*(8192+8192)=163840 bytes.
And TDataset will allocate memory for Buffercount (default=10)*(8192
+8192)=163840 bytes.

So, that'll be: 327698 bytes for the two records.
If you fetch more records, only the postgresql-client and TBufDataset
will allocate more memory, but you can do that math yourself.

Now, what if the fields were varchar(100); (ridiculous high, but even
then...) 18+10*(100+100)+10*(100+100)=2018 bytes.

So, by defining a limit on the varchar, you've gained 325680 bytes of
memory.

I think that this little example shows the problem pretty well...

btw: only postgresql supports unlimited varchar's.

regards,
  Joost.

_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to