Skip to content

Instantly share code, notes, and snippets.

@ailabs-software
ailabs-software / pipeline.json
Created November 23, 2019 19:12
JSON data for content case studies cards
{
"id": "9d0fc129-d2c1-4732-96e8-41e4c71e7af6",
"title": "Case Study",
"embedMargin": {
"top": 0,
"right": 0,
"bottom": 0,
"left": 0
},
"items": [
@ailabs-software
ailabs-software / gist:62a869c1c26bab958979a2a2cef95e41
Created November 7, 2019 00:03
cat /proc/cpuinfo on guest that runs postgres + 12 processes that are clients
# cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 42
model name : Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
stepping : 7
microcode : 0x29
cpu MHz : 3200.022
cache size : 8192 KB
@ailabs-software
ailabs-software / query.sql
Last active October 29, 2019 19:55
Slow query
The query with explain:
EXPLAIN ANALYZE
SELECT id AS person_id FROM crm_person
WHERE domain=131 AND
(EXISTS(
SELECT 1 FROM canalytics_content_person_junction
WHERE canalytics_content_person_junction.person_id=crm_person.id AND
EXISTS(SELECT 1 FROM mediaanalytic_play_session ca WHERE ca.person_id=canalytics_content_person_junction.person_id AND
ca.content_name=canalytics_content_person_junction.content_name AND ca.content_id=canalytics_content_person_junction.content_id)));
QUERY PLAN
(function()
{
/** Auto-generated variables */
var myAccountName = "Harry";
// BEGIN DART PROGRAM, COMPILED OF COURSE
import "dart:js";
print( context["myAccountName"] ); // Does not work because myAccountName is in closure, not on global object!
// END DART PROGRAM
@ailabs-software
ailabs-software / app.js
Created October 11, 2019 02:11
JS payload with dart2js output (variables at top are dynamically generated and Dart should be able to read them)
This file has been truncated, but you can view the full file.
(function() {var SW_LOCAL_EXPORTS = {};window["SW_LOCAL_EXPORTS"] = SW_LOCAL_EXPORTS;var SHOPWINDOW_DOMAIN = "laserbounce.shopwindow.io";
window["SHOPWINDOW_DOMAIN"] = SHOPWINDOW_DOMAIN;var SHOPWINDOW_PHONENO = "15162068636";
var __SHOPWIN_MODULE_CONF = {"modules":["shopwindow.SiteAnalytics.SiteAnalyticsClient","shopwindow.SiteOrnaments"],"environment":{"SHOPWINDOW_DOMAIN":"laserbounce.shopwindow.io"}};
{}(function dartProgram(){function copyProperties(a,b){var u=Object.keys(a)
for(var t=0;t<u.length;t++){var s=u[t]
b[s]=a[s]}}var z=function(){var u=function(){}
u.prototype={p:{}}
var t=new u()
if(!(t.__proto__&&t.__proto__.p===u.prototype.p))return false
# EXPLAIN (BUFFERS, ANALYZE)
SELECT maturation_timestamp FROM publish_queue LEFT OUTER JOIN publish ON(publish.id=publish_queue.publish_id)
WHERE status_executed=0 AND funded AND syndicated=true ORDER BY NOT maturation_timestamp IS NULL, maturation_timestamp ASC LIMIT 1;
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=46708.53..46708.54 rows=1 width=8) (actual time=89.679..89.680 rows=1 loops=1)
Buffers: shared hit=40267
-> Sort (cost=46708.53..46713.43 rows=1958 width=8) (actual time=89.679..89.679 rows=1 loops=1)
Sort Key: ((publish_queue.maturation_timestamp IS NOT NULL)), publ
# EXPLAIN (BUFFERS, ANALYZE)
SELECT maturation_timestamp FROM publish_queue LEFT OUTER JOIN publish ON(publish.id=publish_queue.publish_id)
WHERE status_executed=0 AND funded AND syndicated=false ORDER BY NOT maturation_timestamp IS NULL, maturation_timestamp ASC LIMIT 1;
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=54861.93..54861.93 rows=1 width=8) (actual time=60.833..60.833 rows=0 loops=1)
Buffers: shared hit=119987
-> Sort (cost=54861.93..54920.40 rows=23389 width=8) (actual time=60.833..60.833 rows=0 loops=1)
Sort Key: ((publish_queue.maturation_timestamp IS NOT NULL)), p
# EXPLAIN (BUFFERS, ANALYZE)
SELECT maturation_timestamp FROM publish_queue LEFT OUTER JOIN publish ON(publish.id=publish_queue.publish_id)
WHERE status_executed=0 AND funded AND syndicated=false ORDER BY NOT maturation_timestamp IS NULL, maturation_timestamp ASC LIMIT 1;
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=193666.07..193666.08 rows=1 width=8) (actual time=794.110..794.110 rows=0 loops=1)
Buffers: shared hit=62104, temp read=4116 written=4110
-> Sort (cost=193666.07..194976.67 rows=524239 width=8) (actual time=794.109..794.109 rows=0 loops=1)
Sort Key: ((publish_queu
# EXPLAIN ANALYZE
SELECT maturation_timestamp FROM publish_queue LEFT OUTER JOIN publish ON(publish.id=publish_queue.publish_id)
WHERE status_executed=0 AND funded AND syndicated=false ORDER BY NOT maturation_timestamp IS NULL, maturation_timestamp ASC LIMIT 1;
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=193660.99..193660.99 rows=1 width=8) (actual time=668.434..668.434 rows=0 loops=1)
-> Sort (cost=193660.99..194971.58 rows=524239 width=8) (actual time=668.433..668.433 rows=0 loops=1)
Sort Key: ((publish_queue.maturation_timestamp IS NOT NULL)), publish_queue.maturation_timesta
# EXPLAIN ANALYZE SELECT COUNT(*) FROM publish_queue WHERE NOT EXISTS(SELECT 1 FROM publish WHERE id = publish_queue.publish_id);
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Aggregate (cost=444595.43..444595.44 rows=1 width=0) (actual time=4001.970..4001.970 rows=1 loops=1)
-> Merge Anti Join (cost=368.56..444595.43 rows=1 width=0) (actual time=4001.967..4001.967 rows=0 loops=1)
Merge Cond: (publish_queue.publish_id = publish.id)
-> Index Only Scan using publish_queue_publish_id_idx on publish_queue (cost=0.56..226422.09 rows=9668693 width=16) (actual time=0.021..2199.928 rows=9726503 loops=1)
Heap Fetches: 3223208
-> Materialize (cost=0.43..52748.0