Raytracing solutions tend to use a bounding volume hierarchy to accelerate searches for the closest hit along a ray. That means your scene geometry is organized into something like a tree. If a ray misses the bounding volume of one branch of that tree, then the entire branch and all its twigs and leaves can be skipped over.
So, given no other information about the scene contents or the details of the raycasting queries being performed, we'd expect this to scale similarly to other tree search algorithms: ie. logarithmically.
That means raycasting a scene with 1 million triangles will usually be faster than doing the same in a scene with 20 million triangles, but not 20 times faster.
The particular scaling factors will depend on details of your scene geometry (do you have a lot of clusters of geometry well separated from each other, so the BVH can prune lots of it out of the path of your search? Or is all your geometry densely packed in the path of the rays you tend do shoot, so we have to visit most of it during a particular search?), the kinds of raycasting queries you use, and the particular graphics card and driver you're running on.
So as always with performance questions, the best way to get accurate answers for your use case is to build a test and profile the results.