Skip to content

Instantly share code, notes, and snippets.

View workmaster2n's full-sized avatar

Tyler DeWitt workmaster2n

  • Peritus Resource Group
  • Tulsa, OK
View GitHub Profile
@workmaster2n
workmaster2n / EXPLAIN EXTENDED
Created April 23, 2012 17:13
Sorting Across Join
mysql> EXPLAIN EXTENDED SELECT players.LastName, accounts.Name FROM players_to_teams LEFT OUTER JOIN teams ON players_to_teams.team_id = teams.id LEFT OUTER JOIN players ON players_to_teams.player_id = players.id LEFT OUTER JOIN accounts ON accounts.id = teams.account_id WHERE players.LastName != "" AND teams.SportTypeId = 5 ORDER BY players.LastName LIMIT 30\G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: teams
type: ref
possible_keys: PRIMARY,sport_type_id
key: sport_type_id
key_len: 5
ref: const
CREATE
DEFINER=`root`@`localhost`
TRIGGER `mysql_development`.`update_translated_position`
BEFORE UPDATE ON `mysql_development`.`players_to_teams`
FOR EACH ROW
BEGIN
SELECT "NCAApsAbbrev1"
FROM position_translator
WHERE NEW.position = position_translator.RawPosition
SET players_to_teams.translated_position = position_translator.NCAAposAbbrev1;
@workmaster2n
workmaster2n / explain
Created October 1, 2012 17:45
optimize query
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: players
type: index
possible_keys: PRIMARY
key: index_players_on_LastName
key_len: 768
ref: NULL
rows: 10
a:link, a:active, a:visited {
color: #2a83dd;
}
a:hover {
color: #0f58a0;
}
@workmaster2n
workmaster2n / accounts local
Created December 12, 2012 18:40 — forked from anonymous/player_to_team_history local
This query runs 5x slower on my remote staging server than it does on my local dev machine
Table: accounts
Create Table: CREATE TABLE `accounts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`AccountId` varchar(255) DEFAULT NULL,
`AccountIdTemp` varchar(255) DEFAULT NULL,
`HighSchoolTempId` varchar(255) DEFAULT NULL,
`IsActive` tinyint(1) DEFAULT NULL,
`IsVisible` tinyint(1) DEFAULT NULL,
`IsPaidAd` varchar(255) DEFAULT NULL,
`boolean` varchar(255) DEFAULT NULL,
@workmaster2n
workmaster2n / array.rb
Last active December 17, 2015 22:29
Turn points into line_string
result = Point.select(:geom).order(:date_time).group(track_id)
line_strings = []
result.each do |point_group|
line_strings.append(factory.line_string(point_group.to_a))
end
deployer@arcsite:~/apps/arcsite/current$ bundle show paperclip
/home/deployer/.rvm/gems/ruby-1.9.3-p392@arcsite_mysql/gems/paperclip-3.4.2
@workmaster2n
workmaster2n / Gemfile
Last active December 19, 2015 00:19 — forked from mpapis/Gemfile
# Just part of it
gem 'pg'
gem 'rgeo'
gem 'rgeo-shapefile'
gem 'activerecord-postgis-adapter'
gem 'paperclip'
CREATE TABLE public.events
(
id integer NOT NULL DEFAULT nextval('events_id_seq'::regclass),
zone_id integer,
worker_id integer,
duration integer,
start_time time without time zone,
end_time time without time zone,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
@workmaster2n
workmaster2n / conditions
Last active December 20, 2015 05:48
Trying to Grab time_parameters and worker_parameters
CREATE TABLE public.conditions
(
id integer NOT NULL DEFAULT nextval('conditions_id_seq'::regclass),
parameter_id integer,
parameter_type character varying(255),
rule_id integer,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
CONSTRAINT conditions_pkey PRIMARY KEY (id)
)