Please suggest! Will DokuWiki function normaly if there will be up to 500.000 pages within one namespace (that is one folder on the server)?
Yes. The limiting factor is not DokuWiki or how many files in a given directory (namespace) - it'll be the drive and the file system, (don't try this with a MS filesystem though you likely don't have a choice, use ext4
if you do have a choice. Ref.
). At a minimum you'd want a fast drive/s (RAID or SSD).
Will the built-in DokuWiki search handle that number of pages?
Yes - but slowly
How slowly will depend on your server resources - I wouldn't recommend using DokuWiki's search capability for such a large site (there are other search engines you can use instead).