More table or more database for better performance?
Performance shouldn't be a concern: security, consistency, data integrity should be


Security: If each web site has a database this implies that the data for that web site is 
private and separate. So 40000 databases with 10 tables each.
Consistency: managing 40k websites requires utter consistency. Why pick 400x1000 or 4000x100? How will you separate tables? How do you know which site uses which set of tables in which DB?
Data integrity: If you restore one database, do you really want to reset the data for another 399 or 3999 websites too?


So: 40k databases, one per web site.

Finally, do you have 40k web sites or is this premature optimisation?