Skip to content

Instantly share code, notes, and snippets.

@swasheck
swasheck / pg_hba.conf
Created June 1, 2012 19:52
pg_hba.conf
# PostgreSQL Client Authentication Configuration File
# ===================================================
#
# Refer to the "Client Authentication" section in the PostgreSQL
# documentation for a complete description of this file. A short
# synopsis follows.
#
# This file controls: which hosts are allowed to connect, how clients
# are authenticated, which PostgreSQL user names they can use, which
# databases they can access. Records take one of these forms:
@swasheck
swasheck / Makefile
Created October 2, 2012 21:42 — forked from peplin/Makefile
Installation script for PyLucene
# Makefile for building PyLucene
#
# Supported operating systems: Mac OS X, Linux and Windows.
# See INSTALL file for requirements.
# See jcc/INSTALL for information about --shared.
#
# Steps to build
# 1. Edit the sections below as documented
# 2. make
# 3. make install
select getdate() ,
schema_name = sh.name ,
table_name = t.name ,
stat_name = s.name ,
index_name = i.name ,
stat_leading_column =
index_col(quotename(sh.name) + '.' + quotename(t.name),
s.stats_id, 1) ,
s.stats_id ,
s.has_filter ,
@swasheck
swasheck / FISC.sql
Created February 1, 2016 18:51
filtered index selectivity calcs
dbcc traceon(2363,3604)
go
set nocount on;
create table #test (
id int
)
declare @id int = 1;
/*
StatsGrabber.sql
(2014 only)
This script will grab the statistics collections used to generate a query plan and their current state
from the database. Find this section and place your query between the chunks:
/*
@swasheck
swasheck / weather_statsonly.sql
Last active January 5, 2016 21:09
stats-only dump of a weather database
This file has been truncated, but you can view the full file.
/****** Object: Table [dbo].[Element] Script Date: 1/5/2016 1:06:05 PM ******/
/****** Object: Table [dbo].[Element] Script Date: 1/5/2016 1:47:35 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Element](
[ElementCode] [char](4) NOT NULL,
@swasheck
swasheck / YourVeryOwnSO.sql
Last active January 3, 2016 17:29
Inspired by Brent Ozar's post, here's a Gist to parse SO data. Relationships, keys, and indexes not included. Oh yeah, pay attention to the xml source location as you may need to change it.http://www.brentozar.com/archive/2014/01/how-to-query-the-stackexchange-databases/
-- DOWNLOAD YOUR DATA
/*
http://meta.stackoverflow.com/questions/198915/is-there-a-direct-download-link-with-a-raw-data-dump-of-stack-overflow-not-a-t/199303#199303
*/
USE [stack_raw]
GO
/****** Object: Table [dbo].[Badge] Script Date: 12/20/2014 3:08:08 PM ******/
SET ANSI_NULLS ON
GO
@swasheck
swasheck / plan voodoo
Created December 18, 2013 18:10
top io queries with plan compile stats
SELECT
TOP(100)
collection_date = GETDATE(),
database_name = DB_NAME(CAST(pa.dbid AS INTEGER)),
database_name_exec = DB_NAME(CAST(pa.dbid_execute AS INTEGER)),
qs.total_worker_time,
qs.execution_count,
qs.sql_handle,
qs.plan_handle,
qs.creation_time,
@swasheck
swasheck / gist:6625242
Created September 19, 2013 15:30
Extended Event Issue
-- XE Definition
CREATE EVENT SESSION [page_splits] ON SERVER
ADD EVENT sqlos.wait_info(
ACTION (sqlos.task_time,sqlserver.sql_text,package0.collect_system_time)
WHERE ([sqlserver].[database_id]=(18))),
ADD EVENT sqlos.wait_info_external(
ACTION (sqlos.task_time,sqlserver.sql_text,package0.collect_system_time)
WHERE ([sqlserver].[database_id]=(18))),
ADD EVENT sqlserver.page_split(
ACTION(sqlos.task_time,sqlserver.sql_text,package0.collect_system_time)
DECLARE @CounterPrefix NVARCHAR(30)
SET @CounterPrefix = CASE
WHEN @@SERVICENAME = 'MSSQLSERVER'
THEN @CounterPrefix + ''
ELSE 'MSSQL$'+@@SERVICENAME+':'
END;
SELECT
server_name = @@SERVERNAME,
server_instance = @@SERVICENAME,
object_name,