benchmark for this 2 sql statement.

I am having problems on preforming one of my sql statement where by i need to check the existance of the data.

boolean found=false;

Select * from Table_1 where column_1 = '"+username+" ' ";i

if (rs.nest())
  found = true;


I am thinking instead of using the conventional SELECT statement, do you think the perfomance will bb much better if i use this,

boolean found = false;

Select * from Table_1 where MATCH (column_1) Against ('"+ username +" ' ") IN BOOLEAN MODE;

if (


Which one if faster, better from how long?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


In answer to your question,
well the speed of the two statements will vary depending on whether you've got an INDEX on the table.  If both indexes were present, then I would say that the = method would be faster than the fulltext method.  But if the table is properly indexed, then they should both be really fast.

IF you're just trying to check if data exists... then I would also recommend adding a " LIMIT 1" to the end of your statement since the number of entries has no value to the data check.  (this could be the cause of any slowness that you're experiencing since even though you're only using 1 row, the DB retrieves all the rows that match your query if you don't specify a limit).
wjh7554Author Commented:
can you give me some experience how to ultilise the "LIMIT 1"

Yes, i am comparing all senario whereby all the Primary Key, FullText Index are completely set properly.

you just put it at the absolute end of a mysql query.

Select * from Table_1 where column_1 = '"+username+" ' " LIMIT 1;
Select * from Table_1 where MATCH (column_1) Against ('"+ username +" ' ") IN BOOLEAN MODE LIMIT 1;

technicaly LIMIT can take two terms, but it assumes 0 for the second if you don't tell it.  
LIMIT <number of records to retrieve>, [offset from first relevant record]

so by putting a LIMIT 1 on the end mysql will stop retrieving records when it finds the first one

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.