Yes, a time filter will make the query more performant. InfluxDB first
checks the time range to determine which shards must be scanned. It then
checks the tag conditions against the series index to determine which
specific shard files need to be queried. It then pulls the points from disk
to evaluate any field conditions and execute the functions.

SELECT LAST() is something of a special case, however, as the system will
always check the most recent shards first. However, adding SELECT
LAST()...WHERE time > now() - 1h will explicitly force the system to
eliminate any but the most recent shard. I suspect that would improve
performance. Generally speaking you should scope your queries in time to as
narrow a range as reasonable.

On Thu, Jul 7, 2016 at 1:10 PM, <[email protected]> wrote:

> On Thursday, July 7, 2016 at 2:12:50 PM UTC-4, [email protected] wrote:
> > On Thursday, July 7, 2016 at 12:50:48 PM UTC-4, Sean Beckett wrote:
> > > Yes, that's why I recommended it. LAST() is more performant than LIMIT
> 1. How much more performant is highly dependent on your particular schema.
> > >
> > >
> > > On Thu, Jul 7, 2016 at 9:32 AM,  <[email protected]> wrote:
> > > On Thursday, July 7, 2016 at 11:29:23 AM UTC-4, Sean Beckett wrote:
> > >
> > > > Explicitly name each field in the SELECT statement:
> > >
> > > >
> > >
> > > > SELECT LAST(<field_key_1>), LAST(<field_key_2>),
> LAST(<field_key_3>), LAST(<field_key_4>)  FROM measurement
> > >
> > > >
> > >
> > > >
> > >
> > > > Wildcards are not yet allowed inside functions. Follow
> https://github.com/influxdata/influxdb/issues/5750 and
> https://github.com/influxdata/influxdb/issues/5978 for progress on that.
> > >
> > > >
> > >
> > > >
> > >
> > >
> > >
> > > > On Thu, Jul 7, 2016 at 9:03 AM,  <[email protected]> wrote:
> > >
> > > > On Wednesday, July 6, 2016 at 10:22:56 AM UTC-4, Sean Beckett wrote:
> > >
> > > >
> > >
> > > > >
> https://docs.influxdata.com/influxdb/v0.13/query_language/functions/#last
> > >
> > > >
> > >
> > > > >
> > >
> > > >
> > >
> > > > >
> > >
> > > >
> > >
> > > > >
> > >
> > > >
> > >
> > > > > SELECT LAST(<field_key>) FROM measurement
> > >
> > > >
> > >
> > > > >
> > >
> > > >
> > >
> > > > >
> > >
> > > >
> > >
> > > > > On Wed, Jul 6, 2016 at 6:16 AM,  <[email protected]> wrote:
> > >
> > > >
> > >
> > > > > My current query for this is SELECT * FROM measurement ORDER BY
> time DESC LIMIT 1. I'm just wondering if there is a better/faster way that
> this should be accomplished?
> > >
> > > >
> > >
> > > > >
> > >
> > > >
> > >
> > > > >
> > >
> > > >
> > >
> > > > >
> > >
> > > >
> > >
> > > > > --
> > >
> > > >
> > >
> > > > >
> > >
> > > >
> > >
> > > > > Remember to include the InfluxDB version number with all issue
> reports
> > >
> > > >
> > >
> > > > >
> > >
> > > >
> > >
> > > > > ---
> > >
> > > >
> > >
> > > > >
> > >
> > > >
> > >
> > > > > You received this message because you are subscribed to the Google
> Groups "InfluxDB" group.
> > >
> > > >
> > >
> > > > >
> > >
> > > >
> > >
> > > > > To unsubscribe from this group and stop receiving emails from it,
> send an email to [email protected].
> > >
> > > >
> > >
> > > > >
> > >
> > > >
> > >
> > > > > To post to this group, send email to [email protected].
> > >
> > > >
> > >
> > > > >
> > >
> > > >
> > >
> > > > > Visit this group at https://groups.google.com/group/influxdb.
> > >
> > > >
> > >
> > > > >
> > >
> > > >
> > >
> > > > > To view this discussion on the web visit
> https://groups.google.com/d/msgid/influxdb/68d7a627-d5c4-4dbf-8755-e6bf95e14149%40googlegroups.com
> .
> > >
> > > >
> > >
> > > > >
> > >
> > > >
> > >
> > > > > For more options, visit https://groups.google.com/d/optout.
> > >
> > > >
> > >
> > > > >
> > >
> > > >
> > >
> > > > >
> > >
> > > >
> > >
> > > > >
> > >
> > > >
> > >
> > > > >
> > >
> > > >
> > >
> > > > >
> > >
> > > >
> > >
> > > > > --
> > >
> > > >
> > >
> > > > >
> > >
> > > >
> > >
> > > > >
> > >
> > > >
> > >
> > > > > Sean Beckett
> > >
> > > >
> > >
> > > > > Director of Support and Professional Services
> > >
> > > >
> > >
> > > > > InfluxDB
> > >
> > > >
> > >
> > > >
> > >
> > > >
> > >
> > > > That will only work one field, what if I want an entry containing
> multiple fields?
> > >
> > > >
> > >
> > > >
> > >
> > > >
> > >
> > > > --
> > >
> > > >
> > >
> > > > Remember to include the InfluxDB version number with all issue
> reports
> > >
> > > >
> > >
> > > > ---
> > >
> > > >
> > >
> > > > You received this message because you are subscribed to the Google
> Groups "InfluxDB" group.
> > >
> > > >
> > >
> > > > To unsubscribe from this group and stop receiving emails from it,
> send an email to [email protected].
> > >
> > > >
> > >
> > > > To post to this group, send email to [email protected].
> > >
> > > >
> > >
> > > > Visit this group at https://groups.google.com/group/influxdb.
> > >
> > > >
> > >
> > > > To view this discussion on the web visit
> https://groups.google.com/d/msgid/influxdb/95dc2996-024b-405a-ac23-4e1f6b2205e5%40googlegroups.com
> .
> > >
> > > >
> > >
> > > >
> > >
> > > >
> > >
> > > > For more options, visit https://groups.google.com/d/optout.
> > >
> > > >
> > >
> > > >
> > >
> > > >
> > >
> > > >
> > >
> > > >
> > >
> > > > --
> > >
> > > >
> > >
> > > >
> > >
> > > > Sean Beckett
> > >
> > > > Director of Support and Professional Services
> > >
> > > > InfluxDB
> > >
> > >
> > >
> > > So is using LAST better/faster than my originally query (order by time
> desc limit 1)
> > >
> > >
> > >
> > > --
> > >
> > > Remember to include the InfluxDB version number with all issue reports
> > >
> > > ---
> > >
> > > You received this message because you are subscribed to the Google
> Groups "InfluxDB" group.
> > >
> > > To unsubscribe from this group and stop receiving emails from it, send
> an email to [email protected].
> > >
> > > To post to this group, send email to [email protected].
> > >
> > > Visit this group at https://groups.google.com/group/influxdb.
> > >
> > > To view this discussion on the web visit
> https://groups.google.com/d/msgid/influxdb/fb809db2-cda0-40ef-b4d2-07cfd5506ec7%40googlegroups.com
> .
> > >
> > >
> > >
> > > For more options, visit https://groups.google.com/d/optout.
> > >
> > >
> > >
> > >
> > >
> > > --
> > >
> > >
> > > Sean Beckett
> > > Director of Support and Professional Services
> > > InfluxDB
> >
> > Thanks. However, the only problem is that when you use LAST() on
> multiple fields, the Time result returned is 0, even if the LAST() from
> each field comes from the same entry.
>
> Also, what happens when you specify a time filter in the query, does it
> make it more performant, meaning does influx check the time range, and then
> the tags, and then the fields?
>
> --
> Remember to include the InfluxDB version number with all issue reports
> ---
> You received this message because you are subscribed to the Google Groups
> "InfluxDB" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/influxdb.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/influxdb/9000a4ff-d9bc-465d-8630-af4cdf56d2b6%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Sean Beckett
Director of Support and Professional Services
InfluxDB

-- 
Remember to include the InfluxDB version number with all issue reports
--- 
You received this message because you are subscribed to the Google Groups 
"InfluxDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/influxdb.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/influxdb/CALGqCvPjaCPkcxhVNyFuTYWcQQsFJJeLobBmwR_Fckm8huyB%3DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to