Skip to content

Instantly share code, notes, and snippets.

@nik9000
Last active October 30, 2025 20:53
Show Gist options
  • Select an option

  • Save nik9000/ffc2a37d10612d31c2a3a65de88e4548 to your computer and use it in GitHub Desktop.

Select an option

Save nik9000/ffc2a37d10612d31c2a3a65de88e4548 to your computer and use it in GitHub Desktop.
# ./gradlew run -Dtests.heap.size=2g -Dtests.jvm.argline="-da -dsa"
jq . -R --slurp <<CAT > /tmp/big
She should have died hereafter;
There would have been a time for such a word.
Tomorrow, and tomorrow, and tomorrow
Creeps in this petty pace from day to day
To the last syllable of recorded time;
And all our yesterdays have lighted fools
The way to dusty death. Out, out, brief candle!
Life’s but a walking shadow, a poor player
That struts and frets his hour upon the stage
And then is heard no more. It is a tale
Told by an idiot, full of sound and fury
Signifying nothing.
CAT
rm /tmp/bulk
for doc in {1..10000}; do
echo '{"index":{}}' >> /tmp/bulk
echo '{"@timestamp": '$doc', "text": "foo '$(($doc % 10))'", "big": '$(cat /tmp/big)'}' >> /tmp/bulk
done
echo '{
"settings": {
"index.number_of_shards": 100
},
"mappings": {
"properties": {
"@timestamp": { "type": "date" },
"text": { "type": "text" },
"big": { "type": "text" }
}
}
}' > /tmp/idx
curl -uelastic:password -XDELETE localhost:9200/test
curl -uelastic:password -XPUT -HContent-Type:application/json localhost:9200/test --data @/tmp/idx
for docs in {1..100}; do
echo -n "$docs: "
curl -s -uelastic:password -XPOST -HContent-Type:application/json "localhost:9200/test/_bulk?pretty" --data-binary @/tmp/bulk | tee /tmp/bulk_result | grep error
curl -s -uelastic:password -XPOST -HContent-Type:application/json "localhost:9200/test/_flush" | tee /tmp/flush_out > /dev/null
done
curl -s -uelastic:password -XPOST -HContent-Type:application/json "localhost:9200/test/_refresh?pretty"
curl -s -uelastic:password -XPOST -HContent-Type:application/json 'localhost:9200/_query?pretty' -d'{
"query": "FROM test METADATA _source | SORT @timestamp DESC | LIMIT 1000 | KEEP _source",
"pragma": { "node_level_reduction": false },
"profile": true
}' | jq -c '[.profile.drivers[].operators[] | {process_nanos: .status.process_nanos, operator}] | sort_by(.process_nanos)[]'
while true; do
# _source one fetch: 36ms
echo -n '_source one fetch: '
curl -s -uelastic:password -XPOST -HContent-Type:application/json 'localhost:9200/_query?pretty' -d'{
"query": "FROM test METADATA _source | SORT @timestamp DESC | LIMIT 1000 | KEEP _source",
"pragma": { "node_level_reduction": true }
}' | jq .took
# _source n fetch: 240ms
echo -n '_source n fetch: '
curl -s -uelastic:password -XPOST -HContent-Type:application/json 'localhost:9200/_query?pretty' -d'{
"query": "FROM test METADATA _source | SORT @timestamp DESC | LIMIT 1000 | KEEP _source",
"pragma": { "node_level_reduction": false }
}' | jq .took
# ts one fetch: 29ms
echo -n 'ts one fetch: '
curl -s -uelastic:password -XPOST -HContent-Type:application/json 'localhost:9200/_query?pretty' -d'{
"query": "FROM test METADATA _source | SORT @timestamp DESC | LIMIT 1000 | KEEP @timestamp",
"pragma": { "node_level_reduction": true }
}' | jq .took
# ts n fetch: 28ms
echo -n 'ts n fetch: '
curl -s -uelastic:password -XPOST -HContent-Type:application/json 'localhost:9200/_query?pretty' -d'{
"query": "FROM test METADATA _source | SORT @timestamp DESC | LIMIT 1000 | KEEP @timestamp",
"pragma": { "node_level_reduction": false }
}' | jq .took
done
# with
# {"process_nanos":5114110,"operator":"LuceneTopNSourceOperator[shards = [test:0,test:1,test:2,test:3,test:4,test:5,test:6,test:7,test:8,test:9], maxPageSize = 10922, limit = 1000, needsScore = false, sorts = [{\"@timestamp\":{\"order\":\"desc\",\"missing\":\"_first\",\"unmapped_type\":\"date\"}}]]"}
# {"process_nanos":8129777,"operator":"ValuesSourceReaderOperator[fields = [_source]]"}
# without
# {"process_nanos":1950684,"operator":"LuceneTopNSourceOperator[shards = [test:0,test:1,test:2,test:3,test:4,test:5,test:6,test:7,test:8,test:9], maxPageSize = 32, limit = 1000, needsScore = false, sorts = [{\"@timestamp\":{\"order\":\"desc\",\"missing\":\"_first\",\"unmapped_type\":\"date\"}}]]"}
# {"process_nanos":12691089,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":13136069,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":13287548,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":13318622,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":13380481,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":13575580,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":13590549,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":13659231,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":13706563,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":13714301,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":13780050,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":13848610,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":13893019,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":13999549,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":14211482,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":14394044,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":15364041,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":15848752,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":17115393,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":17194816,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":18774697,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":18803246,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":19103991,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":19199052,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":19541363,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":19634147,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":19650856,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":19689051,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":19720253,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":19810199,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":19962716,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":20004285,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":20136816,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":20138976,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":20508055,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":20537981,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":21233228,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":21333367,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":23448984,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
# {"process_nanos":23473450,"operator":"ValuesSourceReaderOperator[fields = [@timestamp, _source]]"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment