Recursive queries in Teradata do not allow to use DISTINCT in the recursion itself as well as any AGG functions/ subqueries.
Is there any trick how to handle duplicated relationship during doing a recursion?
Related
In a Cosmos DB collection (SQL API) with 2 million documents, there are from 1-10 that match a subset query. From within the subset result, I am looking to obtain a single nth item from the subset, unless the item number I use as a parameter is beyond the last one in the subset, in which case I want to get the first (rolling over).
I am familiar with CTEs in TSQL (How do I get the nth row in a SQL Server table?) to do something like this, but not in Cosmos DB (although kind of like SELECT rows between two dates in azure cosmos db).
Can anyone point me in the right direction for this?
Thanks.
While improving the performance of a Kusto query, I came across the shuffle strategy for join/summarize. I can clearly see the performance benefits of this strategy for my query, which has high cardinality for the join/summarize key.
While reading the shuffle query Kusto documentation, it seemed that the strategy will be ignored when there are nested shuffle operators.
When the shuffled operator has other shuffle-able operators, like summarize or join, the query becomes more complex and then hint.strategy=shuffle won't be applied.
My query uses nested summarize and join (with shuffle) but I also clearly see performance gains. My query pattern:
Table1
| summarize hint.strategy=shuffle arg_max(Timestamp) by Device, Interface
| join hint.strategy=shuffle (Table2) on Device, Interface
Does a query like this benefit from shuffling?
Also, does the Kusto query planner avoid any problematic shuffle if present always? Basically I wanted to rest assured that there might only be perf issues with a wrongly used/authored shuffle and not data issues.
Please note that the article of shuffle query suggests to use hint.shufflekey in case you have nested summarize/join operators but it requires that the nested summarize/join operators have the same group-by/join key.
so in your example above, apply the following (I'm assumging that Device has a high cardinality (and you can remove/keep the shuffle strategy from the summarize, keeping/removing it will be the same behavior as long as you specify the shuffle key on the join which wraps this summarize):
Table1
| summarize arg_max(Timestamp) by Device, Interface
| join hint.shufflekey=Device (Table2) on Device, Interface
when i used to work with Ms SQL server i used to create for example this query
Select Sum(Amount * Price) from table
Can this be done in GOOGLE FIRE BASE this is so important before i start a new project
Note there will be more queries like that
How can we run such queries and how complex it can be
I relay need to either choose fire base or use normal SQL server to work on the project
Thanks
Cloud Firestore does not support native aggregation queries. However, you can use client-side transactions or Cloud Functions to easily maintain aggregate information about your data.
Cloud Firestore provides powerful query functionality for specifying which documents you want to retrieve from a collection or collection group.
You can also chain multiple where() methods to create more specific queries (logical AND). However, to combine the equality operator (==) with a range or array-contains clause (<, <=, >, >=, or array-contains
Cloud Firestore does not support the following types of queries:
Queries with range filters on different fields, as described in the previous section.
Logical OR queries. In this case, you should create a separate query for each OR condition and merge the query results in your app.
Queries with a != clause. In this case, you should split the query into a greater-than query and a less-than query. For example, although the query clause where("age", "!=", "30") is not supported, you can get the same result set by combining two queries, one with the clause where("age", "<", "30") and one with the clause where("age", ">", 30).
I'm curious about what's the performance change if adding more joins? is there join number limitation? e.g. if greater than a value, the performance will be degraded. thanks.
Maximum Number Of Tables In A Join
SQLite does not support joins containing more than 64 tables. This limit arises from the fact that the SQLite code generator uses bitmaps with one bit per join-table in the query optimizer.
SQLite uses a very efficient O(N²) greedy algorithm for determining the order of tables in a join and so a large join can be prepared quickly. Hence, there is no mechanism to raise or lower the limit on the number of tables in a join.
see :http://www.sqlite.org/limits.html
I would to know more about query optimizer in sqlite. For order of join, on the website there are only
When selecting the order of tables in a join, SQLite uses an efficient
polynomial-time algorithm. Because of this, SQLite is able to plan
queries with 50- or 60-way joins in a matter of microseconds.
but where are the details, what is the specific function?
See
The SQLite Query Planner: Joins:
http://www.sqlite.org/optoverview.html#joins
The Next Generation Query Planner:
http://www.sqlite.org/queryplanner-ng.html