IRC log for #udbug on 20080423

14:52.33*** join/#udbug fungus (n=olsonl@bromine.sosstaffing.com)
15:12.24*** join/#udbug fungus (n=olsonl@bromine.sosstaffing.com)
15:24.50*** join/#udbug brasto (n=brasto@166.70.44.49)
15:24.50*** mode/#udbug [+o brasto] by ChanServ
16:01.33*** join/#udbug SunSparc (n=sparky@66.7.114.125)
16:10.42brastoinfobot, sic SunSparc
16:10.49brastoinfobot, sick SunSparc
16:10.49infobotACTION fetches Hagrid's Fluffy and sicks Fluffy on SunSparc.
16:11.16brastopractices pushing his 'k' key a few times
16:13.49SunSparcNice Fluffy.  Good boy.
16:25.54eggyknapgenerally spells that version of "sic[k]" without the k
16:26.21eggyknaphttp://en.wiktionary.org/wiki/sic
16:28.44*** join/#udbug fungus (n=olsonl@bromine.sosstaffing.com)
16:33.30brastoah, that's what I had thought originally, but when infobot responded to sick instead of sic, I thought I spelled it wrong
16:33.36brasto~lart infobot
16:33.36infobotaccelerates a free AOL cd to 50,000 rpm and lets brasto feel it
16:33.42brastolol
16:33.48brasto~dumb bot
16:33.48infobotstupid human
17:09.32eggyknapheh
17:21.50brastoHere's a query that finds the count of each domain for users in a table called 'logins':
17:21.59brastoSELECT
17:21.59brasto<PROTECTED>
17:22.00brasto<PROTECTED>
17:22.00brastoFROM logins
17:22.00brastoGROUP BY Domain
17:22.00brastoORDER By Count DESC
17:22.10brastoanyone know a better way to do that?
17:22.31brastoI'm running this query on MySQL
17:23.12brastothe result was suprising to me.  I thought hotmail would have the most, but Yahoo does.
17:25.26eggyknapLooks like the right way to do it.
17:28.47brastoI might try using some variables at the beginning of the statement to simplify the way the query looks, but it's not all that complicated anyway...
17:29.32brastonow i'm working on a way to make that query use a percent instead of a count
17:29.48eggyknapfigures it would make it more complicated to add "simplifying" variables :)
17:30.26eggyknapYou'll have to have a subquery to get the percent. One suggestion: make sure you don't end up with a correlated subquery.
17:30.49eggyknapAnd you could probably just use count(1) instead of count(substring(...
17:36.57brastocount(1)?
17:38.52brastocool, that does work...
17:39.11brastohere's the percent subquery:
17:39.13brastoCOUNT(SELECT id FROM logins WHERE cancel_date != '0000-00-00')
17:39.20brastothat's not working...
17:39.30brastosubquery for the denominator
17:40.59brastoany ideas eggyknap DexterTheDragon fungus SunSparc unum or macnewbold ?
17:42.20fungusDoes the subquery work when run by itself?
17:42.35fungusIs cancel_date NULL?
17:43.00brastoyep, it works
17:43.04brastoby itself
17:43.18brastoNull isn't allowed
17:43.22brastoin that field
17:45.00brastoah, i think the subquery's SELECT should be on the other side of COUNT
17:45.56brastowell... not exactly... that way, but I'll post it in a bit
17:51.04brastoturns out it works either way - the problem was with space
17:51.20brastoyou can't have white space before or after the / when dividing
17:52.09eggyknapgiggles at MySQL's crappy parser
17:52.21eggyknapbrasto: what's the query now?
17:53.29brastoSELECT
17:53.29brasto<PROTECTED>
17:53.29brasto<PROTECTED>
17:53.30brastoFROM logins
17:53.30brastoWHERE cancel_date != '0000-00-00'
17:53.30brastoGROUP BY Domain
17:53.32brastoORDER By Percent DESC
17:53.58brastonow i just need to round the percent off somewhere.
17:58.29eggyknapguesses that that version will be inordinately slow.
17:59.55eggyknapIf mysql supports it, I'd suggest something more like select substring(...) Domain, count(1)/totalcount*100 Percent from logins, (select count(id) totalcount from logins where cancel_date != '0000-00-00') WHERE ...
18:00.13eggyknapThe idea is that the total count is calculated only once, instead of once per row.
18:00.36eggyknapBut perhaps MySQL's optimizer is smart enough to flatten that out, but it's really unlikely
18:00.58brastoI wondered if there was something like that, i'll look for it
18:06.18brastoeggyknap: COUNT(*) is optimized to return very quickly if the SELECT  retrieves from one table, no other columns are retrieved, and there is no WHERE clause.
18:06.44brastothat applies to MyISAM tables
18:06.56brastobut i have a where clause in that subquery
18:07.54brastoperhaps that's where a variable storing the resullts from one query will come in handy if there isn't an equivalent to totalcount().
18:10.05eggyknapI expect a where clause will make that optimization moot. MyISAM tables are a good idea if you're not particularly fond of your data. :)
18:10.28brastolol
18:11.27SunSparcData is over-rated
18:11.37eggyknapData *are* ! :)
18:11.50SunSparcI sit corrected
18:40.05brastoi tried this:
18:40.06brastohttp://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_found-rows
18:40.13brastobut the results were different...
18:46.56brastook, got it:
18:47.01brastoSET @totalrows = (SELECT COUNT(id) FROM logins WHERE cancel_date != '0000-00-00');
18:47.01brastoSELECT
18:47.02brasto<PROTECTED>
18:47.02brasto<PROTECTED>
18:47.02brastoFROM logins
18:47.02brastoWHERE cancel_date != '0000-00-00'
18:47.04brastoGROUP BY Domain
18:47.06brastoORDER By Percent DESC

Generated by irclog2html.pl Modified by Tim Riker to work with infobot.