If find it hard to answer this question.
The correct general answer should be: it depends.
The way I see it with REST: 1. You make an object in your code to call the REST method 2. Call http method 3. Code inside your REST API queries the database 4. Database returns some data 5. REST API code packs up the data into Json and sends it t your client 6. Client receives Json/XML response 7. Map response to an object in your code
- You make an object in your code to call the REST method
- Call http method
- Code inside your REST API queries the database
- Database returns some data
- REST API code packs up the data into Json and sends it to your client
- Client receives Json/XML response
- Map response to an object in your code
There is a mistake in your thought.
And this mistake stems from the fact, that you do not fully understand REST and its principles. REST was not invented, because some nerds found it cool (of course it is) to send Javascript-objects via HTTP over the wire. The main advantage of using HTTP is the possibility of using Caching. If you make your results cacheable, then there are less requests to be made to the DB. And no marshalling is involved. The answer could be delivered directly.
Insofar @Klees answer is not quite right:
When you add complexity the code will run slower. Introducing a REST service if it's not required will slow the execution down as the system is doing more.
When dealing with cacheables results, there is no impact on your application: delivering known answers to known questions could be done via reverse-proxies.