Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
VictoriaMetrics just works!

Aliaksandr Valialkin valyala

:octocat:
VictoriaMetrics just works!
View GitHub Profile
@valyala
valyala / README.md
Last active Aug 6, 2020
Optimizing postgresql table for more than 100K inserts per second
View README.md

Optimizing postgresql table for more than 100K inserts per second

  • Create UNLOGGED table. This reduces the amount of data written to persistent storage by up to 2x.
  • Set WITH (autovacuum_enabled=false) on the table. This saves CPU time and IO bandwidth on useless vacuuming of the table (since we never DELETE or UPDATE the table).
  • Insert rows with COPY FROM STDIN. This is the fastest possible approach to insert rows into table.
  • Minimize the number of indexes in the table, since they slow down inserts. Usually an index on time timestamp with time zone is enough.
  • Add synchronous_commit = off to postgresql.conf.
  • Use table inheritance for fast removal of old data:
@valyala
valyala / go-tool-pprof-readline-support.diff
Created Jan 20, 2016
Add readline support for interactive mode in go tool pprof
View go-tool-pprof-readline-support.diff
diff --git a/src/cmd/pprof/internal/plugin/plugin.go b/src/cmd/pprof/internal/plugin/plugin.go
index a22ec5f..4d545de 100644
--- a/src/cmd/pprof/internal/plugin/plugin.go
+++ b/src/cmd/pprof/internal/plugin/plugin.go
@@ -6,7 +6,6 @@
package plugin
import (
- "bufio"
"fmt"
View dou-fileserver.go
// Example static file server. Serves static files from the given directory.
package main
import (
"flag"
"fmt"
"log"
"strconv"
"strings"
@valyala
valyala / spew.go
Created Apr 28, 2012
Spew implementation ( https://github.com/varnish/spew ) in golang
View spew.go
package main
import (
"flag"
"fmt"
"io"
"net"
"os"
"os/signal"
"strings"
View word_chains_solution.cpp
// This is a solution for the Word Chains problem described
// at http://socialcam.com/jobs/problems .
//
// The problem.
//
// Two words are connected by a word chain if it is possible to change one into
// the other by making a series of single-character changes, such that every
// intermediate form is also a word. For example, CAT and DOG are connected with
// a word chain because CAT, COT, COG and DOG are all words. DEMONIC and
// UMBRELLA are not.
You can’t perform that action at this time.