I use this query on big massive of records.
I don't know what .month() and .year() does.
Are they the functions, which works on python level, or are they just
a functions, which form some query for database? (I use postgres)
So, if .month() and .year() executes on each record, I think, it's too
slow.
But if it executes one time per query, it can be faster than 1st.

On 31 мар, 01:53, Kenneth Lundström <kenneth.t.lundst...@gmail.com>
wrote:
> For some reason I think query2 would be faster, but it s just a gut
> thought. Can t base it on anything, not even experience.
>
> And I think your first query doesn t include first day of month at the
> moment.
>
> Kenneth
>
>
>
>
>
>
>
> > start_date = datetime(year=show_year, month=show_month, day=1, hour=0,
> > minute=0, second=0)
> >      if show_month == 12:
> >          end_date = datetime(year=show_year+1, month=1, day=1, hour=0,
> > minute=0, second=0)
> >      else:
> >          end_date = datetime(year=show_year, month=show_month+1, day=1,
> > hour=0, minute=0, second=0)
>
> > There are two same queries:
>
> > datequery1 = (db.indications.date>  start_date)&(db.indications.date<
> > end_date)
> > datequery2 =
> > (db.indications.date.year()==show_year)&(db.indications.date.month()==show_ 
> > month)
>
> > I think, the first is faster. Am I right?

Reply via email to