• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 12:56
CET 17:56
KST 01:56
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
ByuL: The Forgotten Master of ZvT30Behind the Blue - Team Liquid History Book19Clem wins HomeStory Cup 289HomeStory Cup 28 - Info & Preview13Rongyi Cup S3 - Preview & Info8
Community News
Weekly Cups (March 9-15): herO, Clem, ByuN win22026 KungFu Cup Announcement6BGE Stara Zagora 2026 cancelled12Blizzard Classic Cup - Tastosis announced as captains18Weekly Cups (March 2-8): ByuN overcomes PvT block5
StarCraft 2
General
Weekly Cups (March 9-15): herO, Clem, ByuN win Weekly Cups (August 25-31): Clem's Last Straw? Blizzard Classic Cup - Tastosis announced as captains Potential Updates Coming to the SC2 CN Server Weekly Cups (March 2-8): ByuN overcomes PvT block
Tourneys
2026 KungFu Cup Announcement [GSL CK] #2: Team Classic vs. Team Solar [GSL CK] #1: Team Maru vs. Team herO RSL Season 4 announced for March-April PIG STY FESTIVAL 7.0! (19 Feb - 1 Mar)
Strategy
Custom Maps
Publishing has been re-enabled! [Feb 24th 2026] Map Editor closed ?
External Content
The PondCast: SC2 News & Results Mutation # 517 Distant Threat Mutation # 516 Specter of Death Mutation # 515 Together Forever
Brood War
General
ASL21 General Discussion BGH Auto Balance -> http://bghmmr.eu/ Gypsy to Korea BW General Discussion BSL 22 Map Contest — Submissions OPEN to March 10
Tourneys
[Megathread] Daily Proleagues [BSL22] Open Qualifiers & Ladder Tours IPSL Spring 2026 is here! ASL Season 21 Qualifiers March 7-8
Strategy
Simple Questions, Simple Answers Soma's 9 hatch build from ASL Game 2 Fighting Spirit mining rates Zealot bombing is no longer popular?
Other Games
General Games
Nintendo Switch Thread General RTS Discussion Thread Stormgate/Frost Giant Megathread Dawn of War IV Path of Exile
Dota 2
Official 'what is Dota anymore' discussion The Story of Wings Gaming
League of Legends
FTM 2019 new update 24.2.2
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Five o'clock TL Mafia Mafia Game Mode Feedback/Ideas Vanilla Mini Mafia TL Mafia Community Thread
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Mexico's Drug War Canadian Politics Mega-thread Russo-Ukrainian War Thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Manga] One Piece Movie Discussion! [Req][Books] Good Fantasy/SciFi books
Sports
2024 - 2026 Football Thread Formula 1 Discussion Tokyo Olympics 2021 Thread General nutrition recommendations Cricket [SPORT]
World Cup 2022
Tech Support
Laptop capable of using Photoshop Lightroom?
TL Community
The Automated Ban List
Blogs
Funny Nicknames
LUCKY_NOOB
Money Laundering In Video Ga…
TrAiDoS
Iranian anarchists: organize…
XenOsky
FS++
Kraekkling
Shocked by a laser…
Spydermine0240
Unintentional protectionism…
Uldridge
ASL S21 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2210 users

The Big Programming Thread - Page 650

Forum Index > General Forum
Post a Reply
Prev 1 648 649 650 651 652 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
ZenithM
Profile Joined February 2011
France15952 Posts
July 17 2015 14:10 GMT
#12981
On July 17 2015 22:52 BisuDagger wrote:
Show nested quote +
On July 17 2015 22:14 Acrofales wrote:
Almost fits: 149.49 * log(x + 1). The problem is that it increases slightly too fast, and 45 isn't at 225. However, looking at your picture, you don't want 45 at 225 anyway, but slightly over 270, in which case the log increases too slow. A curve fitter should be able to fit this, though, even with so few points. I'd chug it through scipy's curve fitter for you, but I don't have time. Here's the general function:

a + b*log(c*x + d). Give it the following points: f(0) = 0, f(3) = 90, f(15) = 180, f(40) = 270.

Edit: if there is no way of scaling the log to fit these points properly, try a root:

a + b*x^(1/c)

You are correct, I had to edit my post to show 40 @ 270 degrees. I am going to check out scipy's curve fitter. Never heard of it before now.

Show nested quote +
On July 17 2015 22:16 ZenithM wrote:
AngleInDegrees = 10 * (gaugeValue * 50)^0.44 - (something)
with something being between 0 and 4, which ever looks better ;D

I'd try a root in any case.


What I have trouble wrapping my head around is a formula that tackles the whole range at once. Because between 2-5 the difference is 3, 10-15 the difference is 5, 15 to 25 the difference is 10, but then it descales 25-30 a difference of 5, and then 30-40 a difference of 10 lol. If it scaled where the difference was 1,2,3,5,5,10,10,10 that'd be a little be easier to work with.

Anyway, the code I wrote was easily cleaned up. That was written long form just for me to visual see what was happening. Now it is relatively clean and now I see I could even do better but I already committed it and moved on lol.


else if (needlePosition > 25 && needlePosition <= 30)
{
float scaleToMeter = ScaleToDegrees(25, 30, rotate25, rotate30, needlePosition);
this.transform.Rotate(Vector3.right, scaleToMeter);
}

You're right I hadn't looked at the gauge closely enough. You're probably better off hard coding it (like you did, it sounds fine) or picking another gauge picture ;D.
BisuDagger
Profile Blog Joined October 2009
Bisutopia19315 Posts
July 17 2015 14:15 GMT
#12982
On July 17 2015 23:10 ZenithM wrote:
Show nested quote +
On July 17 2015 22:52 BisuDagger wrote:
On July 17 2015 22:14 Acrofales wrote:
Almost fits: 149.49 * log(x + 1). The problem is that it increases slightly too fast, and 45 isn't at 225. However, looking at your picture, you don't want 45 at 225 anyway, but slightly over 270, in which case the log increases too slow. A curve fitter should be able to fit this, though, even with so few points. I'd chug it through scipy's curve fitter for you, but I don't have time. Here's the general function:

a + b*log(c*x + d). Give it the following points: f(0) = 0, f(3) = 90, f(15) = 180, f(40) = 270.

Edit: if there is no way of scaling the log to fit these points properly, try a root:

a + b*x^(1/c)

You are correct, I had to edit my post to show 40 @ 270 degrees. I am going to check out scipy's curve fitter. Never heard of it before now.

On July 17 2015 22:16 ZenithM wrote:
AngleInDegrees = 10 * (gaugeValue * 50)^0.44 - (something)
with something being between 0 and 4, which ever looks better ;D

I'd try a root in any case.


What I have trouble wrapping my head around is a formula that tackles the whole range at once. Because between 2-5 the difference is 3, 10-15 the difference is 5, 15 to 25 the difference is 10, but then it descales 25-30 a difference of 5, and then 30-40 a difference of 10 lol. If it scaled where the difference was 1,2,3,5,5,10,10,10 that'd be a little be easier to work with.

Anyway, the code I wrote was easily cleaned up. That was written long form just for me to visual see what was happening. Now it is relatively clean and now I see I could even do better but I already committed it and moved on lol.


else if (needlePosition > 25 && needlePosition <= 30)
{
float scaleToMeter = ScaleToDegrees(25, 30, rotate25, rotate30, needlePosition);
this.transform.Rotate(Vector3.right, scaleToMeter);
}

You're right I hadn't looked at the gauge closely enough. You're probably better off hard coding it (like you did, it sounds fine) or picking another gauge picture ;D.

I'm sure I could ask Boeing to redesign their aircraft for me. Lol.
ModeratorFormer Afreeca Starleague Caster: http://afreeca.tv/ASL2ENG2
ZenithM
Profile Joined February 2011
France15952 Posts
July 17 2015 14:24 GMT
#12983
Haha tough luck then. I hope airplane web browsers handle HTML 5 + Javascript. I wouldn't dare to ask my pilot to trust Adobe Flash gauge readings.
BisuDagger
Profile Blog Joined October 2009
Bisutopia19315 Posts
July 17 2015 14:26 GMT
#12984
On July 17 2015 23:24 ZenithM wrote:
Haha tough luck then. I hope airplane web browsers handle HTML 5 + Javascript. I wouldn't dare to ask my pilot to trust Adobe Flash gauge readings.

This is done in unity which has HTML5 support. :D
ModeratorFormer Afreeca Starleague Caster: http://afreeca.tv/ASL2ENG2
Manit0u
Profile Blog Joined August 2004
Poland17695 Posts
July 17 2015 19:22 GMT
#12985
Shouldn't it be analog in the first place?
Time is precious. Waste it wisely.
Acrofales
Profile Joined August 2010
Spain18238 Posts
July 17 2015 19:28 GMT
#12986
On July 17 2015 23:10 ZenithM wrote:
Show nested quote +
On July 17 2015 22:52 BisuDagger wrote:
On July 17 2015 22:14 Acrofales wrote:
Almost fits: 149.49 * log(x + 1). The problem is that it increases slightly too fast, and 45 isn't at 225. However, looking at your picture, you don't want 45 at 225 anyway, but slightly over 270, in which case the log increases too slow. A curve fitter should be able to fit this, though, even with so few points. I'd chug it through scipy's curve fitter for you, but I don't have time. Here's the general function:

a + b*log(c*x + d). Give it the following points: f(0) = 0, f(3) = 90, f(15) = 180, f(40) = 270.

Edit: if there is no way of scaling the log to fit these points properly, try a root:

a + b*x^(1/c)

You are correct, I had to edit my post to show 40 @ 270 degrees. I am going to check out scipy's curve fitter. Never heard of it before now.

On July 17 2015 22:16 ZenithM wrote:
AngleInDegrees = 10 * (gaugeValue * 50)^0.44 - (something)
with something being between 0 and 4, which ever looks better ;D

I'd try a root in any case.


What I have trouble wrapping my head around is a formula that tackles the whole range at once. Because between 2-5 the difference is 3, 10-15 the difference is 5, 15 to 25 the difference is 10, but then it descales 25-30 a difference of 5, and then 30-40 a difference of 10 lol. If it scaled where the difference was 1,2,3,5,5,10,10,10 that'd be a little be easier to work with.

Anyway, the code I wrote was easily cleaned up. That was written long form just for me to visual see what was happening. Now it is relatively clean and now I see I could even do better but I already committed it and moved on lol.


else if (needlePosition > 25 && needlePosition <= 30)
{
float scaleToMeter = ScaleToDegrees(25, 30, rotate25, rotate30, needlePosition);
this.transform.Rotate(Vector3.right, scaleToMeter);
}

You're right I hadn't looked at the gauge closely enough. You're probably better off hard coding it (like you did, it sounds fine) or picking another gauge picture ;D.


Yup. I also completely missed that. What weird underlying analog process led to that being a good distribution on the dial?! How do you calibrate that correctly? :O
Sufficiency
Profile Blog Joined October 2010
Canada23833 Posts
Last Edited: 2015-07-17 23:40:26
July 17 2015 23:39 GMT
#12987
Hi TL,

Sorry this isn't "exactly" programming, but I am looking for a "serious" SQL book to study from. What I mean by "serious" is that I know how to write SQL statements, but I want to understand how to write fast and efficient SQL statements and know some deeper level tricks. Basically, I am interested in becoming an expert user, but not a DBA - if that makes any sense.

As far as SQL vendor specificity is concerned, lack of specificity is preferred, but PostgreSQL or Oracle specific would be fine by me as well.

Thanks in advance.
https://twitter.com/SufficientStats
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
July 17 2015 23:52 GMT
#12988
On July 18 2015 08:39 Sufficiency wrote:
Hi TL,

Sorry this isn't "exactly" programming, but I am looking for a "serious" SQL book to study from. What I mean by "serious" is that I know how to write SQL statements, but I want to understand how to write fast and efficient SQL statements and know some deeper level tricks. Basically, I am interested in becoming an expert user, but not a DBA - if that makes any sense.

As far as SQL vendor specificity is concerned, lack of specificity is preferred, but PostgreSQL or Oracle specific would be fine by me as well.

Thanks in advance.

I don't know any of such books, but I think your best bet would be learning how databases work?
The harder it becomes, the more you should focus on the basics.
Sufficiency
Profile Blog Joined October 2010
Canada23833 Posts
July 17 2015 23:55 GMT
#12989
On July 18 2015 08:52 sabas123 wrote:
Show nested quote +
On July 18 2015 08:39 Sufficiency wrote:
Hi TL,

Sorry this isn't "exactly" programming, but I am looking for a "serious" SQL book to study from. What I mean by "serious" is that I know how to write SQL statements, but I want to understand how to write fast and efficient SQL statements and know some deeper level tricks. Basically, I am interested in becoming an expert user, but not a DBA - if that makes any sense.

As far as SQL vendor specificity is concerned, lack of specificity is preferred, but PostgreSQL or Oracle specific would be fine by me as well.

Thanks in advance.

I don't know any of such books, but I think your best bet would be learning how databases work?


I guess that would make sense - to learn its theories. I am sure there are tons of books on this, but any recommendations?
https://twitter.com/SufficientStats
Chocolate
Profile Blog Joined December 2010
United States2350 Posts
July 18 2015 01:31 GMT
#12990
On July 18 2015 08:39 Sufficiency wrote:
Hi TL,

Sorry this isn't "exactly" programming, but I am looking for a "serious" SQL book to study from. What I mean by "serious" is that I know how to write SQL statements, but I want to understand how to write fast and efficient SQL statements and know some deeper level tricks. Basically, I am interested in becoming an expert user, but not a DBA - if that makes any sense.

As far as SQL vendor specificity is concerned, lack of specificity is preferred, but PostgreSQL or Oracle specific would be fine by me as well.

Thanks in advance.

I'm not a SQL expert by any means but in my databases course we were taught that typically SQL implementations have a built in optimizer that usually does most of that for you.
Sufficiency
Profile Blog Joined October 2010
Canada23833 Posts
Last Edited: 2015-07-18 03:34:11
July 18 2015 03:33 GMT
#12991
On July 18 2015 10:31 Chocolate wrote:
Show nested quote +
On July 18 2015 08:39 Sufficiency wrote:
Hi TL,

Sorry this isn't "exactly" programming, but I am looking for a "serious" SQL book to study from. What I mean by "serious" is that I know how to write SQL statements, but I want to understand how to write fast and efficient SQL statements and know some deeper level tricks. Basically, I am interested in becoming an expert user, but not a DBA - if that makes any sense.

As far as SQL vendor specificity is concerned, lack of specificity is preferred, but PostgreSQL or Oracle specific would be fine by me as well.

Thanks in advance.

I'm not a SQL expert by any means but in my databases course we were taught that typically SQL implementations have a built in optimizer that usually does most of that for you.


Is it really that simple though?

For example, are the following three queries the same in terms of performance?

1.

SELECT a.row_a1, b.row_b1
FROM table_a a
INNER JOIN table_b b
ON a.id = b.id and b.row_b2 = 1


2.

SELECT a.row_a1, b.row_b1
FROM table_a a
INNER JOIN (SELECT * FROM table_b where row_b2 = 1) b
ON a.id = b.id


3.

SELECT a.row_a1, b.row_b1
FROM table_a a
INNER JOIN table_b b
ON a.id = b.id and b.row_b2 = 1
WHERE b.row_b2 = 1


My impression is that 2 is better if table_b is big. I don't really know if there is a difference between 1 and 3 performance wise.
https://twitter.com/SufficientStats
Chocolate
Profile Blog Joined December 2010
United States2350 Posts
Last Edited: 2015-07-18 04:11:23
July 18 2015 04:03 GMT
#12992
Look up this thing called relational algebra. Basically my impression is that SQL implementations use relational algebra to reduce / simplify most expressions that are effectively equal, which means they end up similar or equivalent to the DB when it actually executes the queries.
wherebugsgo
Profile Blog Joined February 2010
Japan10647 Posts
Last Edited: 2015-07-18 05:01:48
July 18 2015 05:01 GMT
#12993
what do you guys do when you start a new job and want to ramp up quickly?

I've been taking notes each day in a gdoc and been trying to make a daily recap of the top 3 things I did. Been pretty useful so far but it still feels so shitty to go from being a TL on a project at a different company to knowing absolutely nothing (have to learn entirely new proprietary tech mostly) in a position where everyone tells me it'll take around 6 months to do anything useful.
phar
Profile Joined August 2011
United States1080 Posts
July 18 2015 05:35 GMT
#12994
read docs (if there are any), read code

Get someone to walk you through standing up a local system end to end. Fix some small bug(s).

Even at a place running an entirely internal stack, you should be able to make some impact in << 6 months...
Who after all is today speaking about the destruction of the Armenians?
wherebugsgo
Profile Blog Joined February 2010
Japan10647 Posts
Last Edited: 2015-07-18 05:53:57
July 18 2015 05:52 GMT
#12995
yea I don't mean make no impact within 6 months but not really pull my weight for 6 months. I've heard varying estimates from my colleagues and some friends who work/have worked here and the consensus seems to be 3-6 months ramp up time to at least not feel like you're just treading water the whole time.

At my previous work it was about a month for me but this is definitely a different beast. Everyone here is way smarter than I am lol

also I'm in a slightly different role, not really SWE. My team is like half SWE half SRE across three different continents...it's actually pretty surreal
r3dox
Profile Blog Joined May 2003
Germany261 Posts
July 18 2015 08:08 GMT
#12996
On July 18 2015 14:01 wherebugsgo wrote:
what do you guys do when you start a new job and want to ramp up quickly?.


ask devs to look over their shoulder / do pair programming on "Routine" Tasks in the code base / System. And let them explain most of their steps how/why they do it etc. ask questions while they do it

Do code Review on small Features / bug fixes and understand why that requirement needed to touch all the places it did.
If there are Overall architecture / design Meetings / discussions listen in from time to time.
teamamerica
Profile Blog Joined July 2010
United States958 Posts
Last Edited: 2015-07-18 08:35:49
July 18 2015 08:21 GMT
#12997
On July 18 2015 12:33 Sufficiency wrote:
Show nested quote +
On July 18 2015 10:31 Chocolate wrote:
On July 18 2015 08:39 Sufficiency wrote:
Hi TL,

Sorry this isn't "exactly" programming, but I am looking for a "serious" SQL book to study from. What I mean by "serious" is that I know how to write SQL statements, but I want to understand how to write fast and efficient SQL statements and know some deeper level tricks. Basically, I am interested in becoming an expert user, but not a DBA - if that makes any sense.

As far as SQL vendor specificity is concerned, lack of specificity is preferred, but PostgreSQL or Oracle specific would be fine by me as well.

Thanks in advance.

I'm not a SQL expert by any means but in my databases course we were taught that typically SQL implementations have a built in optimizer that usually does most of that for you.


Is it really that simple though?

For example, are the following three queries the same in terms of performance?

1.

SELECT a.row_a1, b.row_b1
FROM table_a a
INNER JOIN table_b b
ON a.id = b.id and b.row_b2 = 1


2.

SELECT a.row_a1, b.row_b1
FROM table_a a
INNER JOIN (SELECT * FROM table_b where row_b2 = 1) b
ON a.id = b.id


3.

SELECT a.row_a1, b.row_b1
FROM table_a a
INNER JOIN table_b b
ON a.id = b.id and b.row_b2 = 1
WHERE b.row_b2 = 1


My impression is that 2 is better if table_b is big. I don't really know if there is a difference between 1 and 3 performance wise.


On July 18 2015 12:33 Sufficiency wrote:
Show nested quote +
On July 18 2015 10:31 Chocolate wrote:
On July 18 2015 08:39 Sufficiency wrote:
Hi TL,

Sorry this isn't "exactly" programming, but I am looking for a "serious" SQL book to study from. What I mean by "serious" is that I know how to write SQL statements, but I want to understand how to write fast and efficient SQL statements and know some deeper level tricks. Basically, I am interested in becoming an expert user, but not a DBA - if that makes any sense.

As far as SQL vendor specificity is concerned, lack of specificity is preferred, but PostgreSQL or Oracle specific would be fine by me as well.

Thanks in advance.

I'm not a SQL expert by any means but in my databases course we were taught that typically SQL implementations have a built in optimizer that usually does most of that for you.


Is it really that simple though?

For example, are the following three queries the same in terms of performance?

1.

SELECT a.row_a1, b.row_b1
FROM table_a a
INNER JOIN table_b b
ON a.id = b.id and b.row_b2 = 1


2.

SELECT a.row_a1, b.row_b1
FROM table_a a
INNER JOIN (SELECT * FROM table_b where row_b2 = 1) b
ON a.id = b.id


3.

SELECT a.row_a1, b.row_b1
FROM table_a a
INNER JOIN table_b b
ON a.id = b.id and b.row_b2 = 1
WHERE b.row_b2 = 1


My impression is that 2 is better if table_b is big. I don't really know if there is a difference between 1 and 3 performance wise.


I can't imagine a case where query optimizer doesn't put 1st and 3rd to same. I get same query plan for both over a few different combinations I tried.

Without knowing more of your schema it's really impossible to say which would be faster though (1st/3rd or 2nd). It's a function of indices on your table, the size of the tables, the last time you might have run gather stats or analyze on your table -- all these factors go into what to query plan optimizer decides to execute.

For example, if I have an index on table b, column b.id, b.row_2 then for me, 1st,3rd query blows 2nd query out of water in my testing. Because in that case, MySQL is able to use that index, but with the subquery it's not smart enough. But that's in my case. I really can't say for sure what it might decide to do as table grows much larger. I'm not DBA at work but I know they running into issues with query plans changing as table size grows (but that's Oracle).

The MySQL refpages have probably been on of the most useful things for me, If you really want to become an expert, you should read the refpages for your specific database, since as you can see, queries that reduce to the same result set can be executed differently and that result really comes down to the DB you're using to get the most out of it.

Here's a transcipt of me talking to my database trying a few queries, but in general this is useless to anyone not me since your database will have different indices, table size, and useage patterns.

Sorry I don't have any exact advice, just thought I'd throw in my 2cents.

edit: some practical links:
http://patshaughnessy.net/2014/11/11/discovering-the-computer-science-behind-postgres-indexes
http://use-the-index-luke.com/

+ Show Spoiler +

ysql> SELECT COUNT(*) FROM replays_buid;
ERROR 1146 (42S02): Table 'app.replays_buid' doesn't exist
mysql> SELECT COUNT(*) FROM replays_buildevent;
+----------+
| COUNT(*) |
+----------+
| 7193800 |
+----------+
1 row in set (5.09 sec)

mysql> SELECT COUNT(*) FROM replays_build;
+----------+
| COUNT(*) |
+----------+
| 26507 |
+----------+
1 row in set (0.02 sec)

mysql> SELECT COUNT(b.id)
-> FROM replays_build b
-> INNER JOIN (SELECT * FROM replays_buildevent be WHERE be.name = "SCV") be ON b.id = be.build_id;
+-------------+
| COUNT(b.id) |
+-------------+
| 457551 |
+-------------+
1 row in set (28.22 sec)

mysql> SELECT COUNT(b.id)
-> FROM replays_build b
-> JOIN replays_buildevent be ON b.id = be.build_id
-> WHERE be.name = "SCV";
+-------------+
| COUNT(b.id) |
+-------------+
| 457551 |
+-------------+
1 row in set (0.99 sec)

mysql> SELECT COUNT(*)
-> FROM replays_build b
-> INNER JOIN (SELECT * FROM replays_buildevent be WHERE be.name = "SCV") be ON b.match_id = be.time;
+----------+
| COUNT(*) |
+----------+
| 910866 |
+----------+
1 row in set (38.02 sec)

mysql> SELECT COUNT(b.id)
-> FROM replays_build b
-> JOIN replays_buildevent be ON b.match_id = be.time
-> WHERE be.name = "SCV";
+-------------+
| COUNT(b.id) |
+-------------+
| 910866 |
+-------------+
1 row in set (18.82 sec)

mysql> EXPLAIN EXTENDED
-> SELECT COUNT(b.id)
-> FROM replays_build b
-> JOIN replays_buildevent be ON b.match_id = be.time
-> WHERE be.name = "SCV";
+----+-------------+-------+------+------------------------+------------------------+---------+-------------+---------+----------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+-------+------+------------------------+------------------------+---------+-------------+---------+----------+-------------+
| 1 | SIMPLE | be | ALL | NULL | NULL | NULL | NULL | 6227388 | 100.00 | Using where |
| 1 | SIMPLE | b | ref | replays_build_ff9c4e4a | replays_build_ff9c4e4a | 4 | app.be.time | 1 | 100.00 | Using index |
+----+-------------+-------+------+------------------------+------------------------+---------+-------------+---------+----------+-------------+
2 rows in set, 1 warning (0.00 sec)

mysql> EXPLAIN EXTENDED
-> SELECT COUNT(*)
-> FROM replays_build b
-> INNER JOIN (SELECT * FROM replays_buildevent be WHERE be.name = "SCV") be ON b.match_id = be.time;
+----+-------------+------------+-------+------------------------+------------------------+---------+----------------+---------+----------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+------------+-------+------------------------+------------------------+---------+----------------+---------+----------+-------------+
| 1 | PRIMARY | b | index | replays_build_ff9c4e4a | replays_build_ff9c4e4a | 4 | NULL | 24545 | 100.00 | Using index |
| 1 | PRIMARY | <derived2> | ref | <auto_key0> | <auto_key0> | 4 | app.b.match_id | 253 | 100.00 | NULL |
| 2 | DERIVED | be | ALL | NULL | NULL | NULL | NULL | 6227388 | 100.00 | Using where |
+----+-------------+------------+-------+------------------------+------------------------+---------+----------------+---------+----------+-------------+
3 rows in set, 1 warning (0.00 sec)

mysql> EXPLAIN EXTENDED
-> SELECT COUNT(b.id)
-> FROM replays_build b
-> JOIN replays_buildevent be ON b.id = be.build_id
-> WHERE be.name = "SCV";
+----+-------------+-------+-------+---------------+------------------------+---------+----------------+-------+----------+--------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+-------+-------+---------------+------------------------+---------+----------------+-------+----------+--------------------------+
| 1 | SIMPLE | b | index | PRIMARY | replays_build_ff9c4e4a | 4 | NULL | 24545 | 100.00 | Using index |
| 1 | SIMPLE | be | ref | build_name | build_name | 771 | app.b.id,const | 5 | 100.00 | Using where; Using index |
+----+-------------+-------+-------+---------------+------------------------+---------+----------------+-------+----------+--------------------------+
2 rows in set, 1 warning (0.00 sec)

mysql> SELECT COUNT(b.id)
-> FROM replays_build b
-> INNER JOIN (SELECT * FROM replays_buildevent be WHERE be.name = "SCV") be ON b.id = be.build_id;
+-------------+
| COUNT(b.id) |
+-------------+
| 457551 |
+-------------+
1 row in set (27.81 sec)

mysql> EXPLAIN EXTENDED
-> SELECT COUNT(b.id)
-> FROM replays_build b
-> INNER JOIN (SELECT * FROM replays_buildevent be WHERE be.name = "SCV") be ON b.id = be.build_id;
+----+-------------+------------+-------+---------------+------------------------+---------+----------+---------+----------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+------------+-------+---------------+------------------------+---------+----------+---------+----------+-------------+
| 1 | PRIMARY | b | index | PRIMARY | replays_build_ff9c4e4a | 4 | NULL | 24545 | 100.00 | Using index |
| 1 | PRIMARY | <derived2> | ref | <auto_key0> | <auto_key0> | 4 | app.b.id | 253 | 100.00 | NULL |
| 2 | DERIVED | be | ALL | NULL | NULL | NULL | NULL | 6227388 | 100.00 | Using where |
+----+-------------+------------+-------+---------------+------------------------+---------+----------+---------+----------+-------------+
3 rows in set, 1 warning (0.00 sec)
RIP GOMTV. RIP PROLEAGUE.
Manit0u
Profile Blog Joined August 2004
Poland17695 Posts
Last Edited: 2015-07-18 08:42:44
July 18 2015 08:32 GMT
#12998
On July 18 2015 12:33 Sufficiency wrote:
Show nested quote +
On July 18 2015 10:31 Chocolate wrote:
On July 18 2015 08:39 Sufficiency wrote:
Hi TL,

Sorry this isn't "exactly" programming, but I am looking for a "serious" SQL book to study from. What I mean by "serious" is that I know how to write SQL statements, but I want to understand how to write fast and efficient SQL statements and know some deeper level tricks. Basically, I am interested in becoming an expert user, but not a DBA - if that makes any sense.

As far as SQL vendor specificity is concerned, lack of specificity is preferred, but PostgreSQL or Oracle specific would be fine by me as well.

Thanks in advance.

I'm not a SQL expert by any means but in my databases course we were taught that typically SQL implementations have a built in optimizer that usually does most of that for you.


Is it really that simple though?

For example, are the following three queries the same in terms of performance?

1.

SELECT a.row_a1, b.row_b1
FROM table_a a
INNER JOIN table_b b
ON a.id = b.id and b.row_b2 = 1


2.

SELECT a.row_a1, b.row_b1
FROM table_a a
INNER JOIN (SELECT * FROM table_b where row_b2 = 1) b
ON a.id = b.id


3.

SELECT a.row_a1, b.row_b1
FROM table_a a
INNER JOIN table_b b
ON a.id = b.id and b.row_b2 = 1
WHERE b.row_b2 = 1


My impression is that 2 is better if table_b is big. I don't really know if there is a difference between 1 and 3 performance wise.


It also depends on what kind of data you want from the DB. You could look up some database abstraction stuff and see how they do things (Doctrine is open source, you could definitely check out their hydration modes). It's fairly important to not only optimize your queries, it's just as important to reduce the number of queries and to get back only the stuff you need, without superfluous things.

Some most useful stuff includes COUNT, CONCAT, HAVING and GROUP BY.

Too many times I've seen code execute the query only to do stupid stuff like that:


$query = $queryBuilder
->select('o') // that's equal to *
->from('myTable')
->where('statement)
->getQuery();

$result = $query->getResult();

return count($result);


What it should be:


$query = $queryBuilder
->select('COUNT(o.id)')
->from('myTable')
->where('statement)
->getQuery();

$result = $query->getSingleScalarResult();

return $result;


CONCAT is likewise useful, when you want to display the user's first name + last name for example. Instead of doing concatenation later in the code you can simply select "CONCAT('u.first_name', ' ', 'u.last_name') AS name" and work with that.

You also don't always need objects and should use stuff like getArrayResult() (still speaking about Doctrine since I can't really live without some form of DBAL any more).

Another really important thing is query parametrization. So that you can reuse your queries for different data.


SELECT * FROM Orders WHERE CustomerID =?



INSERT INTO Employees(LastName, FirstName, Title, TitleOfCourtesy,
BirthDate, HireDate, Address, City, Region, PostalCode, Country,
HomePhone, Extension, Photo, Notes, ReportsTo, PhotoPath, rowguid)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)


As a bonus, I present you with this most interesting study regarding DB performance when storing dates and times (tldr: never use timestamps in your db).
Time is precious. Waste it wisely.
phar
Profile Joined August 2011
United States1080 Posts
Last Edited: 2015-07-18 19:45:17
July 18 2015 19:41 GMT
#12999
On July 18 2015 14:52 wherebugsgo wrote:
yea I don't mean make no impact within 6 months but not really pull my weight for 6 months. I've heard varying estimates from my colleagues and some friends who work/have worked here and the consensus seems to be 3-6 months ramp up time to at least not feel like you're just treading water the whole time.

At my previous work it was about a month for me but this is definitely a different beast. Everyone here is way smarter than I am lol

also I'm in a slightly different role, not really SWE. My team is like half SWE half SRE across three different continents...it's actually pretty surreal

Send me a PM, if you're working where I think you're working. There are likely resources internally that can help you out.


Also it is normal (nay, required) for SRE teams to be split across continents, here is the logic:

1) SRE oncall is real (hard core) on call, with proper SLO/SLA for all systems, and for answering pages. That means in normal dev land, if a SWE is on call and a page happens, and they don't answer for 15 minutes maybe it's ok. Oftentimes (depending on the level of requirement) an SRE is acking that shit in like a minute. That means you can't even go take a shit or drive home without clearing it with secondary.

2) You want your SRE to be awake and able to actually triage & solve production issues ASAP when answering a page. (For example an on-call dev waking up at 3 am is not going to actually solve any problem for like 30 minutes, because 3am you're groggy).

-> The solution here is time zone rotations. Some SRE teams will be split across 2 timezones (west coast & Europe is common) later in the evening. West coast on call during daylight hours there, then swap to Europe in the evening. Rinse & repeat. More expansive SRE teams will be split across 3 timezones (usually Australia or the like), only 8 hour shifts.



All that does make it hard to coordinate, because remote teammates can be harder to work with. Requires a lot of proactive communication. Also helps if you get to fly around and meet up with everyone, see what everybody's like in person. You'll realize that for the most part people do have your back, and are interested in helping you succeed - while remotely over email/code reviews/im, people can seem a bit more terse & not as helpful.
Who after all is today speaking about the destruction of the Armenians?
Manit0u
Profile Blog Joined August 2004
Poland17695 Posts
Last Edited: 2015-07-18 22:10:45
July 18 2015 22:06 GMT
#13000
Damn guys, you're using all those acronyms... Could you at least explain what they mean? Google returns way too many possibilities and I'm genuinely curious here.

Random rant continued: Client presentation due the day after tomorrow, had to pull another saturday workday until 7pm, ux designer, half of the devs and all front-end people are on vacation, app looks like shit because every back-end dev was like "functionality is working, I'll just dump all the results wherever to prove it, let the front-end handle it" (I'm part of back-end too, but I had some experience with front-end so I at least made my stuff a bit more managable). My heart says it's fine, my brain says otherwise. Especially that (unlike most clients), this one sent a guy who was developing business apps for a living for years to act as their guy (the very first question he asked was "What's your test coverage?").

I really do feel rather grimdark right now.
Time is precious. Waste it wisely.
Prev 1 648 649 650 651 652 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 7h 4m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
elazer 259
RushiSC 159
Trikslyr128
ProTech121
TKL 115
UpATreeSC 93
JuggernautJason79
BRAT_OK 47
MindelVK 9
StarCraft: Brood War
Britney 24429
Calm 4892
Jaedong 1426
Soma 768
EffOrt 683
Mini 520
Light 300
Shuttle 221
Snow 200
Rush 189
[ Show more ]
actioN 176
Zeus 119
Dewaltoss 99
hero 89
Backho 58
Bonyth 49
sorry 46
Hyun 43
yabsab 27
zelot 25
Hm[arnc] 21
sSak 19
IntoTheRainbow 18
Rock 18
GoRush 17
soO 15
Noble 11
Terrorterran 11
ajuk12(nOOB) 9
NaDa 9
SilentControl 6
eros_byul 1
Barracks 0
Dota 2
Gorgc3932
qojqva3058
BananaSlamJamma238
canceldota56
League of Legends
JimRising 417
Counter-Strike
fl0m3374
pashabiceps1748
byalli266
adren_tv38
Super Smash Bros
Mew2King64
Heroes of the Storm
Khaldor126
Other Games
singsing1879
FrodaN1119
B2W.Neo849
ceh9260
Hui .155
Liquid`VortiX152
Fuzer 142
XaKoH 87
KnowMe85
ArmadaUGS72
QueenE62
Organizations
Dota 2
PGL Dota 2 - Main Stream127
Other Games
BasetradeTV76
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• blackmanpl 3
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• lizZardDota259
League of Legends
• Jankos1717
• Shiphtur277
Other Games
• WagamamaTV232
Upcoming Events
OSC
7h 4m
The PondCast
17h 4m
KCM Race Survival
17h 4m
WardiTV Team League
19h 4m
OSC
20h 4m
Replay Cast
1d 7h
KCM Race Survival
1d 17h
WardiTV Team League
1d 19h
Korean StarCraft League
2 days
RSL Revival
2 days
Maru vs Zoun
Cure vs ByuN
[ Show More ]
uThermal 2v2 Circuit
2 days
BSL
3 days
RSL Revival
3 days
herO vs MaxPax
Rogue vs TriGGeR
BSL
4 days
Replay Cast
4 days
Replay Cast
4 days
Afreeca Starleague
4 days
Sharp vs Scan
Rain vs Mong
Wardi Open
4 days
Monday Night Weeklies
5 days
Sparkling Tuna Cup
5 days
Afreeca Starleague
5 days
Soulkey vs Ample
JyJ vs sSak
Afreeca Starleague
6 days
hero vs YSC
Larva vs Shine
Liquipedia Results

Completed

Proleague 2026-03-16
WardiTV Winter 2026
Underdog Cup #3

Ongoing

KCM Race Survival 2026 Season 1
Jeongseon Sooper Cup
BSL Season 22
CSL Elite League 2026
RSL Revival: Season 4
Nations Cup 2026
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual

Upcoming

ASL Season 21
Acropolis #4 - TS6
2026 Changsha Offline CUP
Acropolis #4
IPSL Spring 2026
BSL 22 Non-Korean Championship
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
NationLESS Cup
Stake Ranked Episode 2
CS Asia Championships 2026
IEM Atlanta 2026
Asian Champions League 2026
PGL Astana 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.