It should happen as soon as PL needs to interact with an image file. When you select a folder in the Folder pane, PL starts displaying images in the image browser. As it prepares to display an image, it has to first look for it in its database. If it’s not there, it adds it. It will read metadata from the image. If it finds an associated XMP file (for RAW images), it uses the metadata from that. If it finds an associated DOP file, it uses that data as well.
So when you visit a folder, it is indexed. Sub-folders are not indexed unless you visit them as well. If you manually request indexing on a folder, it and its sub-folders are indexed.
Before keywords and metadata searches, you could live entirely without the database. PL would still index image data (place it in the database), but you could delete the database on a regular basis without issues. The keyword structure and metadata searches require knowing something about more than just the images you are currently looking at. If you were to delete the database, you would not be able to search for metadata across all images, nor would you be able to view your complete keyword structure.
If you delete the database and index from the top level, PL will know about all the images within that top-level folder. If you index other folders, it will only know about those. However, since info is accumulated with each indexing operation, you could index each sub-folder independently and it would be the same as indexing just the top-level. It requires more manual work and it takes as long or longer, but it might not crash on you.
I suspect the crashing is occurring because of lack of memory, although it could be something else. If it’s a memory problem, indexing the sub-folders might squeak you by.
Photolab.db should be your main database. Photolab.db-shm and Photolab.db-wal are auxiliary files. The three files should be considered a unit. I suspect that these can be deleted (not while PL is running!) and will then be re-generated the next time the database is accessed, but I won’t swear to it. PL uses SQLite for its database. You can get an SQLite DB reader and take a look at what is stored in the file if you want.
Keep in mind that if you delete or rename files outside of PL, their database entries will live on. If you then delete the database and re-index, the database may, indeed, be a lot smaller.