Skip to content

Instantly share code, notes, and snippets.

View VarunVats9's full-sized avatar
🏠
Working from home

VarunVats9

🏠
Working from home
View GitHub Profile
@VarunVats9
VarunVats9 / es-5.json
Created February 29, 2020 18:18
Elasticsearch - nested objects, nested inner hits
// Mapping
PUT /departments >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
{
"mappings": {
"properties": {
"name": {
"type": "text"
},
"employees": {
"type": "nested"
@VarunVats9
VarunVats9 / es-6.json
Last active February 29, 2020 18:40
Elasticsearch - parent-child inner hits, multi level relations
// Inner hits, has_child query
GET /department/_search >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
{
"query": {
"has_child": {
"type": "employee",
"inner_hits": {},
"query": {
"bool": {
"must": [
@VarunVats9
VarunVats9 / es-7.json
Last active February 29, 2020 19:15
Elasticsearch - filter, _source, yml
// Filter
GET /bank/_search >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
{
"query": {
"bool": {
"must": [
{
"match": {
"lastname": "Smith"
}
@VarunVats9
VarunVats9 / latency.markdown
Created July 12, 2023 02:29 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs