Return-Path: X-Original-To: apmail-db-derby-user-archive@www.apache.org Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B7FB2623C for ; Tue, 14 Jun 2011 02:19:09 +0000 (UTC) Received: (qmail 69754 invoked by uid 500); 14 Jun 2011 02:19:09 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 69712 invoked by uid 500); 14 Jun 2011 02:19:09 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 69705 invoked by uid 99); 14 Jun 2011 02:19:09 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Jun 2011 02:19:09 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of masoodmortazavi@gmail.com designates 209.85.215.44 as permitted sender) Received: from [209.85.215.44] (HELO mail-ew0-f44.google.com) (209.85.215.44) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Jun 2011 02:19:03 +0000 Received: by ewy19 with SMTP id 19so2248372ewy.31 for ; Mon, 13 Jun 2011 19:18:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=yKWdQzieViquu1kvhzJnR9eLeBY2jOhhW+HsZLBb1pA=; b=wVDkaCjldQ1U8EhozzNv4Qpp5mKq7xG3NoGJdd+dfnDcZu9gfmoUnK8z9yjEZhmQP1 VdeG6+7QWZ1ouy/MbwgzQ8doqVGFBh1sKbH5nsGrCQucHg7jcDST6xc5SFnkys4O01AR GdquEbHhPcJcWPTIqF1np+FLgz0I2efjS7p6Y= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=lcN0U4YZdNmUP1DHz+hk2GatsNfkwshSc5D/r/vQ3LoWa9BZoTz+NX8g3aZTsu8ET/ 10GFa+O2c9JHuuMDsxd+o6TeBfE7X2jDcb260Q/gNMPK3yv7/eDuLH875Cd772AMVEsL 7N0TQ2OYwnDOV9ocX9mRYIVbGXnAx0TYAyFAA= MIME-Version: 1.0 Received: by 10.14.100.195 with SMTP id z43mr2567788eef.31.1308017921619; Mon, 13 Jun 2011 19:18:41 -0700 (PDT) Received: by 10.14.45.10 with HTTP; Mon, 13 Jun 2011 19:18:41 -0700 (PDT) In-Reply-To: References: Date: Mon, 13 Jun 2011 19:18:41 -0700 Message-ID: Subject: Re: Derby query optimizations / (materialized) Views and Queries From: Masood Mortazavi To: Derby Discussion Content-Type: multipart/alternative; boundary=bcaec52157d193f96904a5a2a709 --bcaec52157d193f96904a5a2a709 Content-Type: text/plain; charset=ISO-8859-1 On Mon, Jun 13, 2011 at 6:39 PM, Masood Mortazavi wrote: > I have a Derby table (T) with 10^7 records. > This table has 5 columns. > I have defined a Derby view (V) on one of those columns. > To produce (V) all of (T) needs to be scanned. > There are about 2000 records that the view (V) contains. > > Now, I "cross" (T) with (V), with an IN clause involving (V). > I have three questions: > [1] Is the optimizer smart enough to to scan only O( (T)*(V) ) times (with > the V comparisons involving in-memory "materialization" of (V)), or will it > be O( (T)*(T) ) or something else? > [2] What is the support that Derby 10.8.1.2 may be offering for > materialized views? > [3] If the answer to [1] is the larger number, would materializing (V) > change things or improve them drastically, i.e. would Derby save the large > (T) sized scan to produce (V), or even better, would it do that and also > bring all of (V), which is rather small, into memory (in large enough chunks > or completely) for the purposes of the cross involving IN? > > With best regards to all good Derby friends, > - m. > I solve the materialization issue by a simple exporting of the view's select query and then importing it. It works well. I will rerun my IN cross query, against the now materialized table to see how much better or worse it does in this particular case. The general gist of my questions above still remain. Regards, Masood --bcaec52157d193f96904a5a2a709 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

On Mon, Jun 13, 2011 at 6:39 PM, Masood = Mortazavi <masoodmortazavi@gmail.com> wrote:
I have a Derby table (T) with 10^7 records.
This table has 5 columns.=A0=
I have defined a Derby view (V) on one of those columns.
To produce= (V) all of (T) needs to be scanned.
There are about 2000 records that = the view (V) contains.

Now, I "cross" (T) with (V), with an IN clause involving (V).=
I have three questions:
[1] Is the optimizer smart enough to to scan= only O( (T)*(V) ) times (with the V comparisons involving in-memory "= materialization" of (V)), or will it be O( (T)*(T) ) or something else= ?
[2] What is the support that Derby 10.8.1.2 may be offering for materialize= d views?
[3] If the answer to [1] is the larger number, would materializ= ing (V) change things or improve them drastically, i.e. would Derby save th= e large (T) sized scan to produce (V), or even better, would it do that and= also bring all of (V), which is rather small, into memory (in large enough= chunks or completely) for the purposes of the cross involving IN?

With best regards to all good Derby friends,
- m.

I solve the materialization issue by = a simple exporting of the view's select query and then importing it. It works well.
I will rerun my IN cross query, against the now materiali= zed table to see how much better or worse it does in this particular case. =
The general gist of my questions above still remain.=A0

Regards,
Masood


--bcaec52157d193f96904a5a2a709--