-1

Which approach is faster in MySQL ? Implementing a binary tree with MySQL and PHP(Codeigniter).

1) When only one query can update a lots of rows (Insertion of a node in tree using Nested Sets )

2) By using procedure and some if else logic and loops , reducing the number of rows-say, the number of rows to be updated in this approach is half than the previous one. (Implementing the tree with adjacency list - going upward till root and updating each root)

Earlier i had asked this question binary-tree-using-php-mysql But didnt get response . Thats why asked this question which somewhat what I have to know atleast.

Please Help Me !

1
  • if the 2nd approach updates half row, it should take less time, but if the procedure and loop logic is implemented in php then the time required may be higher. Commented Mar 24, 2012 at 9:46

3 Answers 3

1

Updating the only rows that needs to be updated is apparently faster.

I see no reason though why it cannot be done with one query.

Sign up to request clarification or add additional context in comments.

3 Comments

could you please help me with this question too ??? stackoverflow.com/questions/9775720/…
or some resource , how to assess performance of alternative solutions in MySQl
I can't. There is no real life problem in it. While abstract description can be far from the real needs
0

UPDATE is much faster when update a lot of rows in single table, it just rewrites table with new data.

Comments

0

On my MySQL servers, the second approach is the fastest solution even if you use a transaction with many updates.

1 Comment

I don't know exactly why but I think it comes from the index regeneration.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.