Return-Path: X-Original-To: apmail-cayenne-user-archive@www.apache.org Delivered-To: apmail-cayenne-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 42FC09E79 for ; Thu, 15 Mar 2012 16:35:48 +0000 (UTC) Received: (qmail 50542 invoked by uid 500); 15 Mar 2012 16:35:48 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 50475 invoked by uid 500); 15 Mar 2012 16:35:48 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 50465 invoked by uid 99); 15 Mar 2012 16:35:48 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Mar 2012 16:35:48 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [209.85.210.41] (HELO mail-pz0-f41.google.com) (209.85.210.41) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Mar 2012 16:35:41 +0000 Received: by dadv6 with SMTP id v6so6215726dad.14 for ; Thu, 15 Mar 2012 09:35:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding:x-gm-message-state; bh=pMuRbaZxEObRGDarAlF1Aw9wHcXdFXnHU2WXb5iyEHw=; b=iOPgdiKxFSlGjkQ2+nsDKgIxDKG9KGmA38Ybi1Mb8MsHl6uqdzMlKlqcds/eWYgAsl GeO3LUsfV2X8gMqWaEUCq3OnST+4lbwtUYJDNyndZJ2sJppQ58AyUJiXDXB6o3FfpEVf J8gkllccHOLDZD6CWNnjYPJNGJnfjiQib5+aNpg96SG5AJhmZSJ80QRZc7d+7vvDvEXK zmDJsf4oBhQF1BQ/O+dBVy5/XR1HrLiyEGtpp+LQJAgPAXlQF9fE5qbMag49UXcNbUFI k+9GM3W9G62QXud4AaNrnuZa8WiuhyZaj76aYKIGw8HWjfLkHlKHvt6Qp27TKAZf+6V/ vcDw== Received: by 10.68.213.8 with SMTP id no8mr5912842pbc.144.1331829320961; Thu, 15 Mar 2012 09:35:20 -0700 (PDT) MIME-Version: 1.0 Received: by 10.68.222.132 with HTTP; Thu, 15 Mar 2012 09:35:00 -0700 (PDT) In-Reply-To: References: From: Michael Gentry Date: Thu, 15 Mar 2012 12:35:00 -0400 Message-ID: Subject: Re: Howto Include Time/Date Functions in Query Expressions To: user@cayenne.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQlnmIN3eRfc2DigTpafBhg7t8afZkO1sf98RIEQxRb+eltMiy4kPjDkqlRTJfOabXzmdW0J X-Virus-Checked: Checked by ClamAV on apache.org Hi Emerson, I'm pretty sure a view will make no difference. The best way to improve performance is to have proper indexes (which a view could also utilize). We have a similar-sized database and query times went from over 1 minute to a few milliseconds once we added an appropriate index. mrg On Thu, Mar 15, 2012 at 11:29 AM, Emerson Casta=F1eda wr= ote: > Hi Mike > > My context: I am handling a table with 50 millions of rows and its size i= s > increasing up =A0every day some thousands. So, my question goes around > performance of the view's solution that you propose. > > Do you think view performance =A0will be better than using SQLTemplate > queries? > > Thanks > > EMERSON > > On Thu, Mar 15, 2012 at 3:07 PM, Mike Kienenberger wr= ote: > >> Depending on your database and usage, another option is to set up a >> view and let the database create derived columns for these, then you >> can treat them as regular Cayenne data object fields. >> >> 2012/3/14 Emerson Casta=F1eda : >> > HI everyone >> > >> > I have a table with a timestamp field, so =A0I'm thinking about how to >> write >> > the next query without define a store procedure, but directly from my >> java >> > code: >> > >> > select * >> > from =A0table1 >> > where >> > id =3D 1 and >> > extract(day from timestampField)=3D'04' and >> > extract(month from timestampField)=3D'04' and >> > extract(year from timestampField)=3D'2009' >> > >> > I'd like to know if that is possible using cayenne, maybe some thing l= ike >> > this? >> > >> > >> > SelectQuery query =3D new SelectQuery(Table1.class); >> > query.andQualifier() >> > >> > OR >> > >> > SelectQuery query =3D new SelectQuery(Table1.class); >> > query.andQualifier( ExpressionFactory.likeIgnoreCaseExp( >> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Table1.timestamppropert= y, "%")); >> > >> > >> > Thank you for your time >> > >> > EMERSON >>