Subject Re: Hanging by a Thread
Author Adam
--- In firebird-support@yahoogroups.com, "inoffensive_2006"
<larryl_ya-hoo_groups@...> wrote:
>
> Hi Folks:
>
> I'm developing an application on Window's XP media,
> a dual core AMD, with Visual C++ 6.0. Firebird 2.0.1
> Super Server and the current IBPP. The database is
> running on the same machine as the application, but
> I'd like to give users the option of running Firebird
> on remote machines.

This is fine, there is no difference (except for performance) whether
the application and database engine are on the same machine or not.
Just be aware that the database file must be on a locally attached
drive to the machine running Firebird, not a share.

>
> The app needs to be able to run on any computer
> with a newer version of Windows.
>
> My application needs to share records between
> independent processes. So I'm saving a few columns
> of each row of the largest table in paged backed
> file mapped nodes of a binary tree. "Page Backed"
> means it's in shared memory, and not a disk file.
>
> Loading this table from the database, withd all
> of the overhead of manipulating the mapped nodes,
> slows the IO. So I want this loaded by a thread,
> while the app's main thread is setting up, with
> other queries on the database, dialogs, and user
> log ins.

Firebird connections are not thread-safe. You will need to create a
connection for each thread. This may explain your hanging if you are
not doing this.

>
> Sometimes the thread to fill the mapped memory
> tree runs fine, and sometimes the thread seems to
> freeze.
>
> The first task the thread performs is a count
> of the records in the database. Then it runs
> a SELECT on a small number of columns of the
> table to fill the mapped tree.
>
> The thread starts it's own transaction, and
> gets a count of the number of rows in the table
> with this SQL
>
> The SQL for this is:
>
> SELECT
> COUNT(*)
> FROM
> CON;
>

Count * is generally a pretty slow operation in a MGA database such as
Firebird, because the data pages must all be visited to do the count.
Locking databases can just store the count against the table metadata,
but MGA databases need to offer a different number depending on the
transaction isolation.

Adam