Rob Vermeulen wrote:
Do we really need a cache?
Need... It seems smarter than invoking the same query over and over
again. In our case 240 times.
Sorry, my sentence implied too much. What I should have written was that
I don't like to have a class variable which is only used at startup and
in a method which does more then the name implies.
The readability of the code would already improve when the exists method
calls a new getAllTables method and a contains on the returned
Collection, but it does not solve the more fundamental issue.
This new cache object shows that we have to create a workaround, because
a class is responsible for something it shouldn't be responsible.
The MMObjectBuilder class checks if it exists in the database, but
actually MMBase should check with the database that the builder exists.
A builder does not have to know that it is stored in a database.
A problem I have seen with db drivers is that the name lookup takes very
long for the db host. The oracle driver for example will always try to
find an ip-address even when you use an ip-address as hostname. WHen it
is a lookup problem then you will see a thread stack (In a thread dump,
kill -3) waiting on a lookup call of a socket
While using the cache this won't be a bug issue anymore.
It still will be a problem in startup time. The lookup is preformed at
connection initialisation time and not at query time. After
initialization the connection (TCP) has allocated the resources in the
network and does not have to do a lookup anymore. The default jdbc.xml
will create 20 connections and that can take a long time.
Another problem I see with the current code is that multiple schemas in
the same database can have the same table name. A getTables could return
a table from a different schema.
*wow*, in our case we didn't trigger this bug because we are always
using basenames... But it seems smart to specify the databaseName,
maybe Marcel will add this bug to his proposal.
Are you referring to the basename in the mmbaseroot.xml? Then you are
still in trouble when you have 2 clouds with the same basename in the
same database. Fortunately, there are not many users in our community
who can afford a "decent" database which supports schemas. These
databases can solve the issues on their level so it is not very blocking :)
Nico
_______________________________________________
Developers mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/developers