In the Control Panel, there is a "Rebuild link database" button. How does it work? What operations are carried out during a link database rebuild?
2 Answers
Retrieved from the SDN site
What is the Links Database:
"Sitecore maintains a table named Links in the database specified in the LinkDatabase section of web.config. This table provides a logical links database for all other databases – the links tables in the other databases are empty by default. Data is exposed through the Sitecore.Links.ItemLink class.
No matter how many databases are processed to create the links database, all entries are stored in a single table in the database".
The rebuild process will essentially update those records.
-
1Do you have any recommendation on how often we need to rebuild link databases?– NirlepNov 8, 2017 at 18:47
-
But what does this effectively "do" for me? Is this Links Database basically the info I see when I check an Item's
Navigation -> Links
? Sep 30, 2019 at 18:34 -
Yes, the information for Navigation->Links is derived from the link database. Jul 9, 2020 at 6:05
Link DB plays key role in managing references across Sitecore items. In simple words, if you select an item and check Navigate>Links, it shows you all the items that refer to the current item and all the items that the current item refers to.
Generally, links in Link Database get updated using Sitecore.Links.ItemEventHandler class. Following events are handled by Sitecore.Links.ItemEventHandler to update the Link DB: item:deleted (OnItemDeleted method), item:copied, item:saved (OnItemSaved method), item:versionRemoved (OnVersionRemoved method)
During development, need may arise to remove an item used extensively within the content tree (template, rendering or form). In such case, we need to find references to an item programmatically. You will need the link DB to updated to show references correctly, else you may end up with broken links in production. This will require a link DB rebuild.