I am implementing an on-disk B-tree, and I have a question about creating new pages. According to the little information I found, when need to add new page I should append a new block to the B-tree file and then read it through buffer manager. I read the code of some databases, and found that basically they all append a new block to file before writing the corresponding buffer. I am wondering can I defer writing to disk when creating new pages.
Can I just keep a next_page_id
record for each file in memory, add new pages in buffer pool, write those pages, and append them to files in the order of page_id
when flushing pages? Are there any problems in this approach?