<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Necessary to order db query by rising column? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Necessary-to-order-db-query-by-rising-column/m-p/125554#M184314</link>
    <description>&lt;P&gt;This may be helpful is you are having a large number of records in the table you are monitoring.&lt;/P&gt;

&lt;P&gt;This is a query I am testing to only sample from the most recent 100000 records using the "order by desc" clause (similar to a unix tail -100000). I then put them back in to chronological sort order with the second "order by" clause. The amount of records can be adjusted depending on  the volume of the feed.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;select * from ( select top 100000 [DateTime],[RouterCallKey],[ANI],[DigitsDialed],[Variable1],[DNIS],[Duration],[TalkTime] from Termination_Call_Detail order by [DateTime] desc ) as T1 order by [DateTime] 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 21 Dec 2015 16:40:44 GMT</pubDate>
    <dc:creator>bandit</dc:creator>
    <dc:date>2015-12-21T16:40:44Z</dc:date>
    <item>
      <title>Necessary to order db query by rising column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Necessary-to-order-db-query-by-rising-column/m-p/125541#M184301</link>
      <description>&lt;P&gt;Is it necessary to include an ORDER BY $rising_column$ in my database tail query? This can be &lt;I&gt;very&lt;/I&gt; expensive on a large database not indexed on that column. (example: using the row's modified_time rather than indexed column create_time)&lt;/P&gt;

&lt;P&gt;Or is Splunk/DBX smart enough to get a result set back and find the maximum of that column for saving until next run.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:42:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Necessary-to-order-db-query-by-rising-column/m-p/125541#M184301</guid>
      <dc:creator>Jason</dc:creator>
      <dc:date>2020-09-28T15:42:59Z</dc:date>
    </item>
    <item>
      <title>Re: Necessary to order db query by rising column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Necessary-to-order-db-query-by-rising-column/m-p/125542#M184302</link>
      <description>&lt;P&gt;The functionality says it should, but long will it wait? But the thing is if you have a timestamp field in table why not filter it in query itself? why to tell splunk to do this expensive operation? And DBX app should always be used cleverly rather than a dumping everything, it is misuse of network resource/processing power at both end.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2014 19:51:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Necessary-to-order-db-query-by-rising-column/m-p/125542#M184302</guid>
      <dc:creator>linu1988</dc:creator>
      <dc:date>2014-01-24T19:51:00Z</dc:date>
    </item>
    <item>
      <title>Re: Necessary to order db query by rising column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Necessary-to-order-db-query-by-rising-column/m-p/125543#M184303</link>
      <description>&lt;P&gt;&lt;I&gt;Edit by OP: This is the exact answer I was looking for (that yes, unfortunately ORDER is required) but it was buried in the comments below:&lt;/I&gt;&lt;/P&gt;

&lt;P&gt;$rising_column$'s ? is from the &lt;B&gt;last record of previous run&lt;/B&gt;.( when new records inserted, for example).&lt;/P&gt;

&lt;P&gt;Therefore, if the ORDER got messed up, it may lose new records.&lt;/P&gt;

&lt;P&gt;============================= original post ================================&lt;/P&gt;

&lt;P&gt;Use Specify SQL query. The example is:&lt;/P&gt;

&lt;P&gt;SQL Query:&lt;BR /&gt;
SELECT * FROM actor {{WHERE $rising_column$ &amp;gt; ?}} ORDER BY last_update&lt;/P&gt;

&lt;P&gt;Tail input settings&lt;BR /&gt;
Rising Column:&lt;BR /&gt;
last_update&lt;/P&gt;

&lt;P&gt;The $rising_column$ here is exactly the same as the ORDER BY field. eventhought it is not necessary, but if the orders are different, it will mess up the data.&lt;/P&gt;

&lt;P&gt;The idea of dbmontail is:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;first run QUERY without {{...}}. which is "SELECT * FROM actor ORDER BY last_update"&lt;/LI&gt;
&lt;LI&gt;continuous runs QUERY with {{....}} from the last_record of $rising_column$. the $rising_column$ will be replaced by "Rising Column" setting. which is "SELECT * FROM actor WHERE last_update &amp;gt; ? ORDER BY last_update". The ? is set to the last_record from the previous run.&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;The more useful cases to specify SQL are actually for constraints, for example:&lt;/P&gt;

&lt;P&gt;SELECT * FROM actor WHERE myfield="abc" {{AND $rising_column$ &amp;gt; ?}} ORDER BY last_update&lt;/P&gt;

&lt;P&gt;so you can have some constraints in SQL.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:43:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Necessary-to-order-db-query-by-rising-column/m-p/125543#M184303</guid>
      <dc:creator>btsay_splunk</dc:creator>
      <dc:date>2020-09-28T15:43:01Z</dc:date>
    </item>
    <item>
      <title>Re: Necessary to order db query by rising column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Necessary-to-order-db-query-by-rising-column/m-p/125544#M184304</link>
      <description>&lt;P&gt;so '?' is the last_record from the previous run and not the biggest number/value from the previous run? Looks like a bug to me.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2014 20:50:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Necessary-to-order-db-query-by-rising-column/m-p/125544#M184304</guid>
      <dc:creator>aelliott</dc:creator>
      <dc:date>2014-01-24T20:50:57Z</dc:date>
    </item>
    <item>
      <title>Re: Necessary to order db query by rising column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Necessary-to-order-db-query-by-rising-column/m-p/125545#M184305</link>
      <description>&lt;P&gt;First SQL is SELECT * FROM actor ORDER BY last_update ASC&lt;BR /&gt;
Continuous SQL is SELECT * FROM actor WHERE last_update&amp;gt;? ORDER BY last_update ASC, the ? is from the last record of previous run.( when new records inserted, for example).&lt;/P&gt;

&lt;P&gt;Therefore, if the ORDER got messed up, it may lose new records.&lt;/P&gt;

&lt;P&gt;The more useful cases are actually for constraints, for example:&lt;/P&gt;

&lt;P&gt;SELECT * FROM actor WHERE myfield="abc" {{AND $rising_column$ &amp;gt; ?}} ORDER BY last_update&lt;/P&gt;

&lt;P&gt;so you can have some constraints in SQL.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:43:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Necessary-to-order-db-query-by-rising-column/m-p/125545#M184305</guid>
      <dc:creator>btsay_splunk</dc:creator>
      <dc:date>2020-09-28T15:43:04Z</dc:date>
    </item>
    <item>
      <title>Re: Necessary to order db query by rising column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Necessary-to-order-db-query-by-rising-column/m-p/125546#M184306</link>
      <description>&lt;P&gt;furthermore, splunk events are based on event timestamp. it doesn't matter the order of inputting into it. all events come with their timestamp, that is the order of events.&lt;BR /&gt;
the only case that will have the event order of importing is when you don't describe timestamp in dbmon and the retrieved fields don't contain any timestamp fields. then dbx will use the importing time as the timestamp for each event. so now you may see the different order of events as you expected.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2014 20:55:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Necessary-to-order-db-query-by-rising-column/m-p/125546#M184306</guid>
      <dc:creator>btsay_splunk</dc:creator>
      <dc:date>2014-01-24T20:55:29Z</dc:date>
    </item>
    <item>
      <title>Re: Necessary to order db query by rising column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Necessary-to-order-db-query-by-rising-column/m-p/125547#M184307</link>
      <description>&lt;P&gt;the previous run of SQL will provide a value of last $rising_column$ which is persisted in dbx. the coming run will pick it up and execute the SQL with &amp;gt; ?. so $rising_column$ in fact has to be distinct, and it is "rising or ASC".&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:43:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Necessary-to-order-db-query-by-rising-column/m-p/125547#M184307</guid>
      <dc:creator>btsay_splunk</dc:creator>
      <dc:date>2020-09-28T15:43:06Z</dc:date>
    </item>
    <item>
      <title>Re: Necessary to order db query by rising column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Necessary-to-order-db-query-by-rising-column/m-p/125548#M184308</link>
      <description>&lt;P&gt;there is an "interval" field you can set up if you want to slow down.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2014 21:11:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Necessary-to-order-db-query-by-rising-column/m-p/125548#M184308</guid>
      <dc:creator>btsay_splunk</dc:creator>
      <dc:date>2014-01-24T21:11:02Z</dc:date>
    </item>
    <item>
      <title>Re: Necessary to order db query by rising column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Necessary-to-order-db-query-by-rising-column/m-p/125549#M184309</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;
I could confirm that if you need to monitor DB and have to get only the largest value from a column you need to order it by ORDER BY. As per the database concept the records will always be inserted in the order it is provided. The order by column / sorting manipulates the data and shows it to us like we want. So when you don't put the data in order the tail command will never know which is where! As per the tail command it only monitors the latest records.&lt;/P&gt;

&lt;P&gt;if the value is greater than the previous monitored value and indexed then it will take all the records after than. The results are inconsistent. So it's better to order by with some time field  rather than numeric/int field which doesn't suggest you the latest updates. Larger database query also should be filtered to returned only near part records rather than whole Table.&lt;/P&gt;

&lt;P&gt;FYI: I had tested with a integer column and rising column always returns all the records if the newest record is greater than last indexed record and if record is smaller nothing is indexed&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2014 21:13:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Necessary-to-order-db-query-by-rising-column/m-p/125549#M184309</guid>
      <dc:creator>linu1988</dc:creator>
      <dc:date>2014-01-24T21:13:19Z</dc:date>
    </item>
    <item>
      <title>Re: Necessary to order db query by rising column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Necessary-to-order-db-query-by-rising-column/m-p/125550#M184310</link>
      <description>&lt;P&gt;DBX does filter timestamp field in table if doesn't specify. The drawback is if you have multiple timestamp fields? it will pick up the first one it found.&lt;BR /&gt;
Use Specify SQL can allow to do constraints such as:&lt;/P&gt;

&lt;P&gt;SQL Query: SELECT * FROM actor WHERE to_year(last_update)&amp;gt;2013.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:43:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Necessary-to-order-db-query-by-rising-column/m-p/125550#M184310</guid>
      <dc:creator>btsay_splunk</dc:creator>
      <dc:date>2020-09-28T15:43:09Z</dc:date>
    </item>
    <item>
      <title>Re: Necessary to order db query by rising column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Necessary-to-order-db-query-by-rising-column/m-p/125551#M184311</link>
      <description>&lt;P&gt;it only monitors the rising_field. If you have a field which is filling time and splunk monitors every 1 hour what is the point in running a query for whole day?just query for last hour data. &lt;/P&gt;

&lt;P&gt;Basic tail functionality is just to tail the newer record rather than indexing everything..&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2014 21:29:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Necessary-to-order-db-query-by-rising-column/m-p/125551#M184311</guid>
      <dc:creator>linu1988</dc:creator>
      <dc:date>2014-01-24T21:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: Necessary to order db query by rising column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Necessary-to-order-db-query-by-rising-column/m-p/125552#M184312</link>
      <description>&lt;P&gt;This sounds like a good idea for an enhancement request. Instead of thinking of a sql table being a list of events ordered by time, think of a sql table with fields that have a timestamp with objects that are modified, that then could be turned into events by simply making the rising column the modified date and not having to worry about what order splunk is getting them in. Thus making event logs from any ordinary Application.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2014 21:41:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Necessary-to-order-db-query-by-rising-column/m-p/125552#M184312</guid>
      <dc:creator>aelliott</dc:creator>
      <dc:date>2014-01-24T21:41:42Z</dc:date>
    </item>
    <item>
      <title>Re: Necessary to order db query by rising column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Necessary-to-order-db-query-by-rising-column/m-p/125553#M184313</link>
      <description>&lt;P&gt;Definitely. Anyone who has a large database that can not reasonably use an ORDER BY command due to excessive load placed on a database should support this enhancement! If only databases could do | where ... | sort ..., rather than | sort ... | where ... Ah, the flexibility of Splunk's search language.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2014 16:44:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Necessary-to-order-db-query-by-rising-column/m-p/125553#M184313</guid>
      <dc:creator>Jason</dc:creator>
      <dc:date>2014-01-27T16:44:17Z</dc:date>
    </item>
    <item>
      <title>Re: Necessary to order db query by rising column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Necessary-to-order-db-query-by-rising-column/m-p/125554#M184314</link>
      <description>&lt;P&gt;This may be helpful is you are having a large number of records in the table you are monitoring.&lt;/P&gt;

&lt;P&gt;This is a query I am testing to only sample from the most recent 100000 records using the "order by desc" clause (similar to a unix tail -100000). I then put them back in to chronological sort order with the second "order by" clause. The amount of records can be adjusted depending on  the volume of the feed.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;select * from ( select top 100000 [DateTime],[RouterCallKey],[ANI],[DigitsDialed],[Variable1],[DNIS],[Duration],[TalkTime] from Termination_Call_Detail order by [DateTime] desc ) as T1 order by [DateTime] 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Dec 2015 16:40:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Necessary-to-order-db-query-by-rising-column/m-p/125554#M184314</guid>
      <dc:creator>bandit</dc:creator>
      <dc:date>2015-12-21T16:40:44Z</dc:date>
    </item>
    <item>
      <title>Re: Necessary to order db query by rising column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Necessary-to-order-db-query-by-rising-column/m-p/125555#M184315</link>
      <description>&lt;P&gt;NEVER convert the underlying data when you don't have to, whether in splunk or an underlying relational database.  It's expensive and unnecessary.   &lt;/P&gt;

&lt;P&gt;DON'T DO THIS - &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;SQL Query: SELECT * FROM actor WHERE to_year(last_update)&amp;gt;2013.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;DO THIS INSTEAD -&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;SQL Query: SELECT * FROM actor WHERE last_update&amp;gt; (whatever the date format in your version of SQL is for the constant "2013-12-31")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 31 Jul 2017 14:47:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Necessary-to-order-db-query-by-rising-column/m-p/125555#M184315</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-07-31T14:47:21Z</dc:date>
    </item>
  </channel>
</rss>

