# Multiple MQTT topics or single with switch?

**URL:** <https://discourse.nodered.org/t/multiple-mqtt-topics-or-single-with-switch/80817>\
**Category:** General\
**Tags:** mqtt\
**Created:** [26 August 2023 09:08 UTC](https://discourse.nodered.org/t/multiple-mqtt-topics-or-single-with-switch/80817 "2023-08-26T09:08:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![andre\_x](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@andre\_x](https://discourse.nodered.org/u/andre_x)\
**Post date:** [26 August 2023 09:08 UTC](https://discourse.nodered.org/t/multiple-mqtt-topics-or-single-with-switch/80817/1 "2023-08-26T09:08:01Z")

</div>

Hi all!  
For efficiency is it better to have a single MQTT input node that receives all the topics and then add a switch to divide the topics or is it better to have multiple MQTT input node one for every topic?  
Thanks!

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [26 August 2023 10:11 UTC](https://discourse.nodered.org/t/multiple-mqtt-topics-or-single-with-switch/80817/2 "2023-08-26T10:11:34Z")

</div>

Unless you have 1000's of topics to deal with, this is mostly a convenience thing. Every single mqtt node becomes a connection to the mqtt server as a publish/subscription. Mosquitto can handle easily 100k connections on light hardware.

However, you can also easily combine similar topics by using wildcards. Depending on your setup. You can read [about best practices here](https://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices/).

No need to worry about any efficiency gains in the context of node-red I believe.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [26 August 2023 10:27 UTC](https://discourse.nodered.org/t/multiple-mqtt-topics-or-single-with-switch/80817/3 "2023-08-26T10:27:00Z")

</div>

Yes. Either you split it with a switch node or the mqtt node “splits” it for you. So it’s going to be magical either way. Do whichever suits your layout/understanding better especially when you come back to it in 6 months time.

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [26 August 2023 23:26 UTC](https://discourse.nodered.org/t/multiple-mqtt-topics-or-single-with-switch/80817/4 "2023-08-26T23:26:52Z")

</div>

> [@dceejay](#):
>
> So it’s going to be magical either way

🧙 @dceejay The wizard has spoken 🪄

DCJ edit —- Good old autocorrect. Should have read “marginal “

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [9 September 2023 23:27 UTC](https://discourse.nodered.org/t/multiple-mqtt-topics-or-single-with-switch/80817/5 "2023-09-09T23:27:39Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
