Skip to content

Instantly share code, notes, and snippets.

View kgorman's full-sized avatar

Kenny Gorman kgorman

View GitHub Profile
insert/s query/s update/s delete/s getmore/s command/s flushes/s mapped vsize res faults/s % locked % idx miss conn time
18843 0 0 0 0 2 0 108652 108899 42858 119 0.813 0 3 17:29:13
18306 0 0 0 0 2 0 108652 108899 42866 118 0.804 0 3 17:29:14
19170 0 0 0 0 2 0 108652 108899 42875 131 0.801 0 3 17:29:15
20586 0 0 0 0 2 0 108652 108899 42886 130 0.816 0 3 17:29:16
20733 0 0 0 0 2 0 108652 108899 42896 131 0.801 0 3 17:29:17
20605 0 0 0 0 2 0 108652 108899 42902 130 0.819 0 3 17:29:18
20025 0 0 0 0 2 0 108652 108899 42912 136 0.822
> var arr=db.test.find({}, {'$diskLoc': 1}).limit(20).showDiskLoc()
> for(var i=0; i<arr.length(); i++) {
printjson(arr[i].$diskLoc.offset/512)
}
3241650.34375
3241650.4453125
>
time commits rollbks blksrd blkshit bkends seqscan seqtprd idxscn idxtrd ins upd del locks hit load active
01-07-2010.16:17:16 330187 0 374322 1295623 124 0 0 330186 334309 0 13402 0 304 77.58 05 87
01-07-2010.16:17:26 329443 0 375055 1291125 124 0 0 329440 333474 0 13451 0 299 77.49 06 85
01-07-2010.16:17:36 331094 0 376139 1298404 124 0 0 331093 335178 0 13546 0 353 77.54 06 117
01-07-2010.16:17:46 332328 0 377137 1303615 124 0 0 332327 336409 0 13547 0 311
@kgorman
kgorman / mongodbcheats.js
Last active March 1, 2024 19:16
MongoDB cheat sheet
/* MongoDB cheat sheet */
// replication lag via serverStatus()
db._adminCommand( { serverStatus : 1 , repl ; 2 } )
// stats
db.stats()
db.foo.stats()
// size of BSON of some query
-- PostgreSQL cheat sheet
--postgres is set up to use local.6 which is syslog'd to sflog001
--slow query log is /var/log/localmessages
--config files are always in /data/friend/*.conf
--vacuums are set via cfengine, we use both manual and auto. vacuums/analyze help with frozen id's being recouped, and thus TX'id's not going over 2b thus causing massing shutdown/reset. Fix it to exp/imp high TX tables.
--to log into psql: psql -U postgres -d <DB> (usually friend)
public void run(){
double N = 20000;
for ( int i=0; i<N; i++ ){
BasicDBObject o = new BasicDBObject( "_id" , UPTO.getAndIncrement() );
coll.insert( o );
}
db.getLastError(2); // commit
}
.....
public static void query()
throws Exception {
db.getLastError(2,2,false); // make sure socket is clear
List<Thread> all = new ArrayList<Thread>();
for ( int i=0; i<NUM_THREADS; i++ )
all.add( new Runner() );
long start = System.currentTimeMillis();
int before = UPTO.get();
#!/home/kgorman/python/bin/python
#
# simple load test script
#
import datetime, os, time, sys, random
import pymongo
import settings
from pymongo import ASCENDING, DESCENDING
from pymongo import Connection
#!/home/kgorman/python/bin/python
# script to make sample data for testing
#
import datetime
import pymongo
import time
import sys
import random
import settings
exp xx/xx@xx tables='baz' file='test1.dmp' consistent=y
Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
With the Partitioning option
Export done in US7ASCII character set and AL16UTF16 NCHAR character set
server uses WE8ISO8859P1 character set (possible charset conversion)
About to export specified tables via Conventional Path ...
. . exporting table BAZ 1000000 rows exported
EXP-00091: Exporting questionable statistics.
EXP-00091: Exporting questionable statistics.