Is it possible to avoid refreshing the entire database when saving or creating a single script?

Every time I make any changes to a script, big or small, Unity takes upwards of 30s refreshing the asset database. I’ve seen it pushing two minutes before. I’m just wondering if there’s someway to change what it’s reloading/compiling. Or even to figure out what might be slowing it down. This happens with new projects as well. It’s been going on for so long, I don’t know if it was ever faster.

I’m using 2020.1.2f1, got 8GB RAM, and an Intel Core i5-4460 3.2GHz cpu - if any of that helps.

Scripts do not really go into the assetdatabase since they are not assets. All scripts get compiled to one or multiple assembly files (DLLs). Your game as well as the Unity editor only directly works with the compiled code. You can not compile a single script file since a lot of your code depend on each other.

You can use assembly definition files to split your code base into seperate assemblies. However you would have to take care about dependencies between your assemblies. You should only use them if you can split your code into logical seperate parts. Those can help to cut down the compilation time in large projects. However depending on your dependencies and what you actually changed it might not be that much. For example if you look at the example diagram in the documentation, when you change something in a script that belongs to the “Library.dll” assembly, Unity has to recompile that assembly (obviously) and every assembly that depends on this assembly. So it would also need to recompile the “Stuff.dll” and since “Main.dll” depends on that it will also get recompiled.

Apart from the compilation time it’s also possible that the actual bottleneck might be your serialized data. Whenever any code is recompiled, Unity has to serialize everything, destroy all managed objects, shutdown the scripting runtime, do the recompile, start up the runtime and deserialize all objects. If you have a lot of serialized data or custom inefficient serialization logic it will slow down the whole process.