Hi,
Ok - makes sense that it's slow - type link is a varchar 180 - indexing that is going to have a huge penalty and will create huge indicies.
From webnotes.model.db_schema on line 30 link is defined as (assuming I am looking in the right place):
,'link': ('varchar', '180')
If you want to have efficient foreign keys these need to be integers - quite a few orm's (ie rails orm, and django orm) automatically define 'id' columns for all
tables and use these are primary keys - having had another look at the database it looks like you use 'name' (varchar 120) as the primary key. This will also
create indexes for 'name' and is also going to be slow compared to having an integer based primary key.
Having not looked at enough of the code I can't tell how hard it would be to adjust it to use integers for record lookups, but I suspect this is something that you
will have to do for larger ERP installations or they will become unusable.
By changing your foreign keys to integers you'll be able to have them indexed, foreign key constraints enabled and still have manageable index sizes.
In the longer term - it may also be worth looking into an ORM like SQLAlchemy to replace the one you have built for this app - it will let you run erpnext against
other databases as well which might be something your future/bigger enterprise customers might want.
Best,
Damian