Click here to Skip to main content
15,884,176 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Epic method to check if database table contains any suitable rows Pin
Ondřej Linhart9-Nov-11 6:57
Ondřej Linhart9-Nov-11 6:57 
GeneralRe: Epic method to check if database table contains any suitable rows Pin
BobJanova10-Nov-11 6:03
BobJanova10-Nov-11 6:03 
GeneralRe: Epic method to check if database table contains any suitable rows Pin
AspDotNetDev10-Nov-11 6:40
protectorAspDotNetDev10-Nov-11 6:40 
GeneralRe: Epic method to check if database table contains any suitable rows Pin
BobJanova10-Nov-11 23:21
BobJanova10-Nov-11 23:21 
GeneralRe: Epic method to check if database table contains any suitable rows Pin
AspDotNetDev11-Nov-11 6:35
protectorAspDotNetDev11-Nov-11 6:35 
GeneralRe: Epic method to check if database table contains any suitable rows Pin
RobCroll10-Nov-11 23:56
RobCroll10-Nov-11 23:56 
GeneralRe: Epic method to check if database table contains any suitable rows Pin
Ondřej Linhart11-Nov-11 5:41
Ondřej Linhart11-Nov-11 5:41 
GeneralRe: Epic method to check if database table contains any suitable rows Pin
James H1-Dec-11 2:33
James H1-Dec-11 2:33 
Select Count(*) has to do the fuzzy like search on the whole table just to show rows that match might exist - so it will probably do a full table scan (if start of like is a %)

better is to let SQL return as soon as it has found one row that matches - so use exists - e.g.

String.Format("SELECT 1  WHERE EXISTS (SELECT 1 FROM data WHERE oznacenie LIKE '{0}')", data)


That way SQL can stop looking after the first row it finds that matches. Depending on size of table this can make a huge difference in performance. This will return 0 or 1 records to the rowcount which you can get using ExecuteScalar return
GeneralRe: Epic method to check if database table contains any suitable rows Pin
Mel Padden16-Nov-11 10:00
Mel Padden16-Nov-11 10:00 
GeneralRe: Epic method to check if database table contains any suitable rows Pin
prasun.r23-Nov-11 3:10
prasun.r23-Nov-11 3:10 
GeneralThis is pretty special. PinPopular
Mel Padden3-Nov-11 7:30
Mel Padden3-Nov-11 7:30 
GeneralRe: This is pretty special. PinPopular
QuiJohn3-Nov-11 8:01
QuiJohn3-Nov-11 8:01 
GeneralRe: This is pretty special. Pin
Mel Padden3-Nov-11 9:17
Mel Padden3-Nov-11 9:17 
GeneralRe: This is pretty special. Pin
Bernhard Hiller3-Nov-11 22:20
Bernhard Hiller3-Nov-11 22:20 
GeneralRe: This is pretty special. Pin
Abinash Bishoyi3-Nov-11 23:26
Abinash Bishoyi3-Nov-11 23:26 
GeneralRe: This is pretty special. Pin
BobJanova3-Nov-11 23:55
BobJanova3-Nov-11 23:55 
GeneralRe: This is pretty special. Pin
Firo Atrum Ventus6-Nov-11 14:22
Firo Atrum Ventus6-Nov-11 14:22 
GeneralRe: This is pretty special. Pin
Reiss6-Nov-11 23:56
professionalReiss6-Nov-11 23:56 
GeneralRe: This is pretty special. Pin
JackDingler16-Nov-11 9:43
JackDingler16-Nov-11 9:43 
GeneralHow to waste time calling the database multiple times PinPopular
Nathan D Cook25-Oct-11 5:47
Nathan D Cook25-Oct-11 5:47 
GeneralRe: How to waste time calling the database multiple times PinPopular
Bernhard Hiller25-Oct-11 20:35
Bernhard Hiller25-Oct-11 20:35 
GeneralRe: How to waste time calling the database multiple times Pin
CDP180228-Oct-11 1:51
CDP180228-Oct-11 1:51 
GeneralRe: How to waste time calling the database multiple times Pin
Sander Rossel29-Oct-11 5:34
professionalSander Rossel29-Oct-11 5:34 
GeneralRe: How to waste time calling the database multiple times Pin
prasun.r7-Dec-11 1:39
prasun.r7-Dec-11 1:39 
RantShocking. Pin
Mel Padden25-Oct-11 4:22
Mel Padden25-Oct-11 4:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.