This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.sales.aggregate([ | |
{ | |
$group: { | |
_id: { | |
month: { $month: "$date" }, | |
department: "$department" | |
}, | |
sales: { $sum: "$amount" } | |
} | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH monthly_sales AS ( | |
SELECT date_trunc('month', sale_date) AS month, department, SUM(sale_amount) AS total_sales | |
FROM sales | |
GROUP BY date_trunc('month', sale_date), department | |
), ranked_sales AS ( | |
SELECT month, department, total_sales, | |
RANK() OVER (PARTITION BY month ORDER BY total_sales DESC) AS rank | |
FROM monthly_sales | |
), previous_month_sales AS ( | |
SELECT month, department, total_sales, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
agg01.push({ | |
$setWindowFields: { | |
partitionBy: '$deviceData', | |
sortBy: { | |
timeStamp: 1 | |
}, | |
output: { | |
movingAverage: { | |
$avg: '$measurement', | |
window: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SQL> SELECT * FROM PROVENDB.PROVENDBREQUESTS WHERE ID=:request_id; | |
ID REQUESTTYPE | |
---------- ------------ | |
REQUESTJSON | |
---------------------------------------------------------------------------------------------------- | |
STATUS STATUSDAT | |
------------ --------- | |
MESSAGES | |
---------------------------------------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SQL> set lines 100 | |
SQL> | |
SQL> BEGIN | |
2 :request_id := PROVENDBORACLE.FVALIDATEREQUEST( | |
3 proofid => :proof_id | |
4 ); | |
5 END; | |
6 / | |
PL/SQL procedure successfully completed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SQL> SELECT * FROM PROVENDB.PROVENDBREQUESTS WHERE ID=:request_id; | |
ID REQUESTTYPE | |
---------- ------------ | |
REQUESTJSON | |
------------------------------------------------------------------------------------------------------------------------------------------------- | |
STATUS STATUSDAT | |
------------ --------- | |
MESSAGES | |
------------------------------------------------------------------------------------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SQL> set long 30000 | |
SQL> var request_id NUMBER | |
SQL> var proof_id char | |
SQL> var proof clob | |
SQL> set pages 10000 | |
SQL> | |
SQL> BEGIN | |
2 :request_id := PROVENDBORACLE.FANCHORREQUEST( | |
3 TABLENAME => 'PROVENDBDEMO.CONTRACTSTABLE', | |
4 COLUMNLIST => 'CONTRACTDATA,METADATA', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mongo> mongoTuning.aggregationExecutionStats(explainOut); | |
1 $CURSOR ( ms 3505 returned:1183307) | |
2 IXSCAN ( iotts_ix ms:85 keys:1183307 nReturned:1183307) | |
3 PROJECTION_COVERED ( ms:115 nReturned:1183307) | |
4 $GROUP ( ms 1224 returned:5) | |
5 $SORT ( ms 0 returned:5) | |
Totals: ms: 4736 keys: 1183307 Docs: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mongo> function stageTimes(explan) { | |
var prevMS=0; | |
explan.stages.forEach(stg => { | |
print(Object.keys(stg)[0], stg.executionTimeMillisEstimate + 0-prevMS); | |
prevMS=stg.executionTimeMillisEstimate; | |
}); | |
} | |
mongol> stageTimes(explainOut); | |
$cursor 3505 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var explainOut=db.iotNoTimeSeries.explain('executionStats').aggregate([ | |
{ $match:{ "deviceData":{ $gt:5 } } } , | |
{ $group:{ _id:{ "deviceData":"$deviceData" }, | |
"measureMent-avg":{$avg:"$measureMent"} | |
} }, | |
{ $sort:{ "measureMent-avg":-1 }}, | |
]); |
NewerOlder