News Reader on RjSteinert.com | RSS Feed Latest news from http://rjsteinert.com/reader http://reader.rjsteinert.com http://feedproxy.google.com/~r/ExplainExtended/~3/2-8bPLMvoAI/ Tue, 24 Aug 2010 11:00:38 -0800 20 latest unique records From Stack Overflow: I have a logfile which logs the insert/delete/updates from all kinds of tables. I would like to get an overview of for example the last 20 people which records where updated, ordered by the last update (datetime DESC) A common solution for such a task would be writing an aggregate query with ORDER BY and LIMIT: SELECT person, MAX(ts) AS last_update FROM logfile GROUP BY person ORDER BY last_update DESC LIMIT 20 What’s bad in this solution?... http://explainextended.com/?p=4884 http://feedproxy.google.com/~r/ExplainExtended/~3/1LTxEYxTEL8/ Thu, 15 Jul 2010 11:00:25 -0800 Questions I had tons of work the last month and got a whole bunch of questions in the queue which I haven’t answered yet. Pawel, Mark, Kate, Felix, Andrew, Ludwig, Santos, Jeremy, John, another John, Anjan and Dave — I do remember about you! Will try to resume the normal blogging schedule the next week. Keep subscribed! http://explainextended.com/?p=4866 -23.95 -46.31 http://feedproxy.google.com/~r/ExplainExtended/~3/B_HJ3f9XSLE/ Wed, 30 Jun 2010 11:00:34 -0800 Indexing for ORDER BY / LIMIT Answering questions asked on the site. Frode Underhill asks: I have some applications that are logging to a MySQL database table. The table is pretty standard on the form: timeBIGINT(20) sourceTINYINT(4) severityENUM textVARCHAR(255) , where source identifies the system that generated the log entry. There are very many entries in the table (>100 million), of which 99.9999% are debug or info messages. I’m making an interface for browsing this log, which means I’ll be doing... http://explainextended.com/?p=4831 http://feedproxy.google.com/~r/ExplainExtended/~3/XgrjLM-z3p0/ Mon, 21 Jun 2010 11:00:49 -0800 GROUP_CONCAT in SQL Server I’m finally back from my vacation. Tunisia’s great: dates, Carthage, sea and stuff. Now, to the questions. Mahen asks: Create a table called Group: Group id prodname 1 X 1 Y 1 Z 2 A 2 B 2 C The resultset should look like this: id prodname 1 X,Y,Z 2 A,B,C Can you please help me to solve the above problem using a recursive CTE? This is out good old friend, GROUP_CONCAT. It’s an aggregate function that returns all strings within a group, concatenated. It... http://explainextended.com/?p=4818