Re: Optimize cascade deletes

From: Giulio Cesare Solaroli (giulio.cesar..mail.com)
Date: Sat Sep 22 2007 - 09:41:19 EDT

  • Next message: Andrus Adamchik: "Re: Optimize cascade deletes"

    On 9/22/07, Andrus Adamchik <andru..bjectstyle.org> wrote:
    >
    > On Sep 21, 2007, at 7:45 PM, Giulio Cesare Solaroli wrote:
    >
    > >
    > > [18:09:40] DELETE FROM clipperz.RCRVRS WHERE ID_RCRVRS = ?
    > > [18:09:40] [batch bind: 968]
    > > [18:09:40] [batch bind: 875]
    > > [......]
    > > [18:09:40] [batch bind: 1177]
    > > [18:09:40] [batch bind: 2792]
    > > [18:11:54] === updated 68 rows.
    > >
    > > In this case, to delete just 68 rows it took more than two minutes,
    > > but I don't know if this time is spent somewhere inside the cayenne
    > > code, or if this is simply the time it took PostgreSQL to "physically"
    > > delete the rows.
    >
    > Initially I suspected performance problems with faulting the
    > relationships, but if the delete itself is so slow, it points to
    > PostgreSQL as the bottleneck as Ari said (coincidentally the query
    > above is a BatchDeleteQuery generated by Cayenne). If it takes that
    > long, something is wrong with the DB. I second a suggestion to try
    > installing PostgreSQL on Mac and it without Parallels.

    I have being able to run the same test on the deployment server, that
    is running on a Solaris zone c/o Joyent, and the issue is much
    smaller:

    [15:21:12] DELETE FROM clipperz.RCRVRS WHERE ID_RCRVRS = ?
    [15:21:12] [batch bind: 1433]
    [15:21:12] [batch bind: 797]
    [....]
    [15:21:12] [batch bind: 55637]
    [15:21:12] [batch bind: 51363]
    [15:21:27] === updated 182 rows.

    So, to delete 182 rows it took about 15 seconds. I was a little
    skeptical, but it really seems that even with such a small operations,
    running from inside a virtual machine can make a huge difference for
    the DB engine.

    15 seconds are a lot of time, but they would be bearable. The problem
    is that I suppose this time will gradually increase with the growth of
    the number of records to delete.

    And if I will end-up needing to delete thousands of records, the
    outcome will be unbearable.

    So I can probably live with this limits for a few more weeks, but I
    need to immediately take action to fix the problem definitely.

    > > The SQL I am expecting Cayenne to generate would look like this:
    > >
    > > delete from user_detail where id_user = <id of the user I want to
    > > delete>;
    >
    > Cayenne 3.0M2 (yet unreleased) supports such functionality via an
    > EJBQL query, but maybe you don't need to do direct DB deletion just yet.

    Where should I start looking to try to integrate the new revision of
    Cayenne in my project in order to take advantage of this feature?

    Thank you very much for your support.

    Best regards,

    Giulio Cesare



    This archive was generated by hypermail 2.0.0 : Sat Sep 22 2007 - 09:41:50 EDT