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 5A3A5976B for ; Thu, 15 Mar 2012 16:53:40 +0000 (UTC) Received: (qmail 19768 invoked by uid 500); 15 Mar 2012 16:53:40 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 19710 invoked by uid 500); 15 Mar 2012 16:53:40 -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 19702 invoked by uid 99); 15 Mar 2012 16:53:40 -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:53:40 +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.213.43] (HELO mail-yw0-f43.google.com) (209.85.213.43) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Mar 2012 16:53:35 +0000 Received: by yhkk6 with SMTP id k6so5113418yhk.16 for ; Thu, 15 Mar 2012 09:53:14 -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=m8XmUyKQUewhcsBRIVruYtxfvewzsnMMiiiz8MifZJE=; b=WsWSwIfIURbqMR9rnQsqnITKCzHUU+yVF8E4Gk5/usT8rRjzyiwFkujzUA8JjWoD4i C4XBbz0sX7apouE5PRdznACInhXwZzEZXkojA9P0CqjDaOhC0WjQw44a5POSz7rFhHkZ Wzsg4Q/FvR2JUyVO0sPpYTPo1J6Ufk2YKggkIFL9lD0iHdcIkz0w6LQ57MXuFWx62GOE iMzTkKIXOGc65NYpAYaHL6yRq9wFKyjMlj/yNFlGoXaf46EH9zO5JGXfWPmFJcGk7miU zHNPH7ypSQLL8NTVuMulCCnfzRreKaP0dBSdtrtjuTk3g+xmAe0flqHVYjSP2EWoO4U/ 9ffw== Received: by 10.68.197.134 with SMTP id iu6mr6096298pbc.123.1331830393993; Thu, 15 Mar 2012 09:53:13 -0700 (PDT) MIME-Version: 1.0 Received: by 10.68.222.132 with HTTP; Thu, 15 Mar 2012 09:52:53 -0700 (PDT) In-Reply-To: References: From: Michael Gentry Date: Thu, 15 Mar 2012 12:52:53 -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: ALoCoQmRMuEemth8WzNO3dv3MD0FVJnvFJ3Hk7BPkT6yDmc1rj/VCn1f930vRb48/kzYc5hfMqNO X-Virus-Checked: Checked by ClamAV on apache.org If the view is backing to 50m records, then it would still have to do a full table scan without indexes. On Thu, Mar 15, 2012 at 12:42 PM, Mike Kienenberger wr= ote: > In this particular case, since the view is just doing data conversion, > I don't think you'd even need indexes, would you? > > On Thu, Mar 15, 2012 at 12:35 PM, Michael Gentry = wrote: >> Hi Emerson, >> >> I'm pretty sure a view will make no difference. =A0The best way to >> improve performance is to have proper indexes (which a view could also >> utilize). =A0We 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 = wrote: >>> Hi Mike >>> >>> My context: I am handling a table with 50 millions of rows and its size= is >>> 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 = wrote: >>> >>>> 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 m= y >>>> 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= like >>>> > 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.timestampprope= rty, "%")); >>>> > >>>> > >>>> > Thank you for your time >>>> > >>>> > EMERSON >>>>