- Create
UNLOGGEDtable. 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 neverDELETEorUPDATEthe 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 zoneis enough. - Add
synchronous_commit = offtopostgresql.conf. - Use table inheritance for fast removal of old data:
This file contains hidden or 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
| require 'active_record' | |
| require 'arel' | |
| # Ruby-like syntax in AR conditions using the underlying Arel layer (Rails >= 3.0). | |
| # | |
| # What you would usually write like this: | |
| # | |
| # User.where(["users.created_at > ? AND users.name LIKE ?", Date.yesterday, "Mary"]) | |
| # | |
| # can now be written like this (note those parentheses required by the operators precedences): |
This file contains hidden or 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
| function getPrimaryCalendar() { | |
| return CalendarApp.getDefaultCalendar(); | |
| } | |
| function getSecondaryCalendar() { | |
| debug(JSON.stringify(PropertiesService.getUserProperties())); | |
| debug(JSON.stringify(PropertiesService.getScriptProperties())); | |
| return CalendarApp.getCalendarById(calendarID()); | |
| } |