Describe the bug
When creating graphs, there is one SQL that is sub-optimal and slows the rate of Graph creation in the current code base.
To Reproduce
Have a large system with many devices and many many data sources and graphs, and attempt to create new ones. The process take much longer then with a newly installed system.
Expected behavior
Cacti should behave well even when there are large numbers of Graphs and Data Sources.