Reputation
24,571
Next tag badge:
95/100 score
23/20 answers
Badges
5 44 87
Newest
 Good Answer
Impact
~1.0m people reached

1h
reviewed Delete Query runs slow in test site on first execution. Why?
15h
reviewed Leave Closed Can we create indexes on views in SQL Server?
20h
comment Outer left join with WHERE loses row
What @AndriyM said ^^^. If you are still confused, 'some value' is the lang('reports_discount') and NULL is the items.name (the NULLs are produced by the LEFT join.)
21h
comment Deferrable Foreign Key Constraints
Does that mean that developers are tools? ;) I would give +1 if I could for that - but I disagree with the "Deferrable constraints are usually wrong."
21h
comment Outer left join with WHERE loses row
because of the where('items.name !=', lang('reports_discount')) Move that condition to the join (ON).
21h
comment How often will a FOR EACH STATEMENT trigger execute if the operation is caused by an FK constraint with UPDATE CASCADE?
@Erwin "FOR EACH ROW of a" or "FOR EACH ROW of t"?
22h
comment PL/SQL recursive lookup with cursor
The query looks fine but the data in your question do not match with the output (rows 1,2,3,5).
23h
revised PL/SQL recursive lookup with cursor
added 36 characters in body
23h
revised PL/SQL recursive lookup with cursor
added 119 characters in body
23h
comment MySQL - Get actual precision and scale of number
Should 0.275 return (0, 3) or (1, 3)?
1d
reviewed Reopen Grouping based on the status, then count its product and the total based on its category ID
1d
comment Can you enforce uniqueness in MySQL based on column in foreign table?
I don't think there is a way to remove the my.a column and keep the uniqueness constraint. But another thing you can do, is replacing the foreign key my (d) references foreign (d) with my (a,d) references foreign (a,d) so what your know see in the database (both column as are complete duplicates) is guaranteed by the database itself.
May
24
comment PostgreSQL: options for large table
I would also help if you showed the definitions of the other 2 tables and a few sample rows. (the choice of a varchar(32) for a primary key does not seem optimal).
May
24
comment PostgreSQL: options for large table
You haven't answered how you are inserting the rows. One INSERT statement for every row? A single INSERT statement for all the million rows? Something in between (say one INSERT for every 1000 rows)?
May
24
comment Dealing with Difficult DBAs
Did you have naming conventions before? What happened when a migration was deployed in the environment but had bugs? I'm not saying that your new process is better in all aspects but perhaps the change has been for some reasons.
May
23
comment Does schema normalization enhances query efficiency
Related: some optimizations (like table elimination) can be used if there are unique/foreign key constraints. Example this question (for Oracle but several DBMS have similar optimizations): dba.stackexchange.com/questions/101051/… So, complex queries (coming from views or otherwise) can be sometimes simplified if there are constraints defined. Simpler queries, simpler plans, less table scans/seeks, more efficient.
May
23
comment Symmetric difference operation in Transact-SQL?
@usr it's actually 2 join-like operations, not 3. Union All is much less costly operation. I agree that FULL JOIN may be more efficient. Testing can reveal which is best. And of course, if more/different columns from each table are needed, my solution is not easily expandable.
May
22
comment Query to flatten schema
@Art which ORM do you use?
May
22
awarded  Good Answer
May
22
comment Query to flatten schema
And it would be good if the naming was consistent (either all table names singular or all plural). The same for column names (i.e. not Users_id and Container_id). These innocent looking minor differences can drive people insane.