Here you find some explanations how the stored procedures [app].[ToIfcStepFromProjectId] or [cp].[ToIfcStep] works:
Creating a Stepfile with the above mentioned stored procedures use a lot of nestet queries. So the time-costs increase exponential with the model size.
Maybe you can speed it up with temporary tables and other methods. If you set some timestamp-outputs, you will find out where the bottle necks are. The point is, that all this methods ends in a procedural way.
The fast procedural way is used in IFC#. See https://github.com/IfcSharp/IfcSharpApps/tree/master/IfcSql/from_ifcSQL
To the importing speed: The IFC#-Api use a bulk-Insert method, wich is much faster than INSERT-statements.
See CurrentModel.ToSql(…) in https://github.com/IfcSharp/IfcSharpApps/tree/master/IfcSharp/hello_project
If this is not fast enough, you can try to work with temporay tables without restrictions and transfer it on server-side to the ifcSQL-tables in a second step.
Hope this helps.