Avoid using rand() in where clauses

I was working today, building a procedure to populate some tables and do some data updates and deletes, for speed testing for one of my FDD sessions.

I decided to use the built-in rand() function of Firebird 2.x in the where clause of updates and deletes, but found out that the execution time was tooking too long to complete. Looking at statistics, it showed weird numbers for Indexed Reads, like, the updates of 5 records generating 80.000 indexed reads in the Primary Key index.

After some debugging, I just found out that rand() was the guilt! I moved it outside the update/delete statement, storing the result in a variable, and using the variable in the where clause. It worked million times faster!

So, moral of history: Don’t use rand() in the where clause of updates and deletes statements. And yep, I know this is quite unusual use 😉

New Firebird tech articles

Morning all,

I’ve uploaded a couple of new documents to the document area. Unfortunately, due to a few problems with VPN timing out over the weekend, I’ve not been able to get the front page updated. I will do soon and the links will be visible.

How the cache works in Firebird:

pdf: http://www.firebirdsql.org/pdfmanual/Firebird-cache.pdf
html: http://www.firebirdsql.org/manual/fbcache.html

That is based on information Ann supplied here on the list a while back. She has permitted me to document it and make a manual out of it.

Firebird Internals:

pdf: http://www.firebirdsql.org/pdfmanual/Firebird-Internals.pdf
html: Not uploaded yet – VPN problems.

A work in progress and as yet fairly incomplete. It will be improved as and when I can. Comments & corrections gratefully received!

Enjoy.

Cheers,
Norman.

Stored Procedures contest winners!

Dear All,

Stored procedures contest is over!
We had 12 submissions for the contest and have chosen 3 winners.

Winners are:

  1. Set of mathematical operations implemented in pure Firebird SQL,
    by pizmon (muirsheendur@gmail.com)
    Download www.mindthebird.com/MathematicOperation.pdf
  2. XML File creation using Firebird in stored procedures, by Fernando
    Medeiros
    Download www.mindthebird.com/ToCreateXML.pdf
  3. SP_ESCAPE and SP_UNESCAPE stored procedures: generate text with
    line feeds, carriage returns, quotes and tabs in Firebird sql scripts,
    by Fabiano Bonin.
    Download www.mindthebird.com/SP_ESCAPE.pdf

Each winner can choose one of the following licenses from MindTheBird  sponsors:

Introductory tips with Jaybird and JRuby

Hello,

I’ve created in Hebrew few tips on how to work with JayBird in Java and JRuby using Firebird. Links for the (google) translated versions:

Get to know FB in 2 minutes – now available in 18 languages

The introductory paper “Get to know Firebird in 2 minutes” is now available in 18 different languages! Thanks for all the translators who contributed.

Languages: English, Czech, Português Brasil, Polish, German, Turkish, Bosnian, Português Portugal, Spanish, Swedish, French, Italian, Hungarian, Bulgarian, Russian, Japanese, Romanian, Hebrew

PS: Some of the translations still need to be updated to the newest document revision (1.3).

1 28 29 30 31 32 78