When the creation of database is included in the commonly running code, sometimes this part of code can be very huge. Also these will not be executed when the program found the database exists already, this will still waste some time when this part is parsing. These database creation code can be seen as "rarely executed code".

At this time, to save this time, we might considering put those files in another PHP file and load the file only when required. However, PHP's "require" and "include" might still read the file or check the existance of the file.

There should be a way to load file dynamically. One possible way is using eval. Here is an example:

index.php:

<?php
// Define some needed constants.
if (!table_exist('abc')) { // In this example, table_exist should be defined by yourself.
   
eval('?>'.file_get_contents('databaseCreation.php'));
}
?>

databaseCreation.php:

<?php
// Check the constants that should be there. If not, exit();
// Here cames huge amount of database creation code.
?>

In this way, the code to create database will not even be parsed or read when not needed.